What will be the output of the following C code? #include <stdio.h> int main() { double *ptr = (double *)100; ptr = ptr + 2; printf("%u", ptr); }
? 102? 104? 108? 116
#include <stdio.h> int main() { double *ptr = (double *)100; ptr = ptr + 2; printf("%u", ptr); }
? 2? 3? 5? Compile time error
Which of the following arithmetic operation can be applied to pointers a and b? (Assuming initialization as int *a = (int *)2; int *b = (int *)3;)
? a+b? a-b? a*b? a/b
What is the size of *ptr in a 32-bit machine (Assuming initialization as int *ptr = 10;)?
? 1? 2? 4? 8
Which of following logical operation can be applied to pointers? (Assuming initialization int *a = 2; int *b = 3;)
? a | b? a ^ b? a & b? None of the mentioned
What will be the output of the following C code? #include <stdio.h> void main() { char *s = "hello"; char *p = s; printf("%c\t%c", *(p + 1), s[1]); }
? h e? e l? h h? e e
What will be the output of the following C code? #include <stdio.h> void main() { char *s = "hello"; char *p = s; printf("%c\t%c", *p, s[1]); }
? e h? Compile time error? h h? h e
What will be the output of the following C code? #include <stdio.h> void main() { char *s = "hello"; char *n = "cjn"; char *p = s + n; printf("%c\t%c", *p, s[1]); }
? h e? Compile time error? c o? h n
What will be the output of the following C code? #include <stdio.h> void main() { char *s = "hello"; char *p = s * 3; printf("%c\t%c", *p, s[1]); }
? h e? l e? Compile time error? l h
What will be the output of the following C code? #include <stdio.h> void main() { char *s= "hello"; char *p = s + 2; printf("%c\t%c", *p, s[1]); }
? l e? h e? l l? h l
What will be the output of the following C code? #include <stdio.h> int main() { void *p; int a[4] = {1, 2, 3, 8}; p = &a[3]; int *ptr = &a[2]; int n = p - ptr; printf("%d\n", n); }
? 1? Compile time error? Segmentation fault? 4
What will be the output of the following C code? #include <stdio.h> int main() { void *p; int a[4] = {1, 2, 3, 4}; p = &a[3]; int *ptr = &a[2]; int n = (int*)p - ptr; printf("%d\n", n); }
? 1? Compile time error? Segmentation fault? 4
What will be the output of the following C code? #include <stdio.h> int main() { int a[4] = {1, 2, 3, 4}; int b[4] = {1, 2, 3, 4}; int n = &b[3] - &a[2]; printf("%d\n", n); }
? -3? 5? 4? Compile time error
What will be the output of the following C code? #include <stdio.h> int main() { int a[4] = {1, 2, 3, 4}; int *p = &a[1]; int *ptr = &a[2]; ptr = ptr * 1; printf("%d\n", *ptr); }
? 2? 1? Compile time error? undefined behavior
What will be the output of the following C code? #include <stdio.h> int main() { int a[4] = {1, 2, 3, 4}; int *ptr = &a[2]; float n = 1; ptr = ptr + n; printf("%d\n", *ptr); }
? 4? 3? Compile time error? Undefined behaviour
What will be the output of the following C code? #include <stdio.h> int main() { int a[4] = {1, 2, 3, 4}; void *p = &a[1]; void *ptr = &a[2]; int n = 1; n = ptr - p; printf("%d\n", n); }
? 1? 4? Compile time error? Depends on the compiler
What will be the output of the following C code? #include <stdio.h> void main() { int a[3] = {1, 2, 3}; int *p = a; printf("%p\t%p", p, a); }
? Same address is printed? Different address is printed? Compile time error? Nothing
What will be the output of the following C code? #include <stdio.h> void main() { char *s = "hello"; char *p = s; printf("%p\t%p", p, s); }
? Different address is printed? Same address is printed? Run time error? Nothing
What will be the output of the following C code? #include <stdio.h> void main() { char *s= "hello"; char *p = s; printf("%c\t%c", p[0], s[1]); }
? Run time error? h h? h e? h l
What will be the output of the following C code? #include <stdio.h> void main() { char *s= "hello"; char *p = s; printf("%c\t%c", *(p + 3), s[1]); }
? h e? l l? l o? l e
What will be the output of the following C code? #include <stdio.h> void main() { char *s= "hello"; char *p = s; printf("%c\t%c", 1[p], s[1]); }
? h h? Run time error? l l? e e
What will be the output of the following C code? #include <stdio.h> void foo( int[] ); int main() { int ary[4] = {1, 2, 3, 4}; foo(ary); printf("%d ", ary[0]); } void foo(int p[4]) { int i = 10; p = &i; printf("%d ", p[0]); }
? 10 10? Compile time error? 10 1? Undefined behaviour
What will be the output of the following C code? #include <stdio.h> int main() { int ary[4] = {1, 2, 3, 4}; int *p = ary + 3; printf("%d\n", p[-2]); }
? 1? 2? Compile time error? Some garbage value
What will be the output of the following C code? #include <stdio.h> int main() { int ary[4] = {1, 2, 3, 4}; int *p = ary + 3; printf("%d %d\n", p[-2], ary[*p]); }
? 2 3? Compile time error? 2 4? 2 somegarbagevalue
What will be the output of the following C code? #include <stdio.h> int main() { int ary[4] = {1, 2, 3, 4}; printf("%d\n", *ary); }
? Compile time error? 1? Compile time error? Undefined variable
What will be the output of the following C code? #include <stdio.h> int main() { const int ary[4] = {1, 2, 3, 4}; int *p; p = ary + 3; *p = 5; printf("%d\n", ary[3]); }
? 4? 5? Compile time error? 3
What are the different ways to initialize an array with all elements as zero?
? int array[5] = {};? int array[5] = {0};? int a = 0, b = 0, c = 0; int array[5] = {a, b, c};? d) All of the mentioned
What are the elements present in the array of the following C code? int array[5] = {5};
? 5, 5, 5, 5, 5? 5, 0, 0, 0, 0? 5, (garbage), (garbage), (garbage), (garbage)? (garbage), (garbage), (garbage), (garbage), 5
Which of the following declaration is illegal?
? int a = 0, b = 1, c = 2; int array[3] = {a, b, c};? int size = 3; int array[size];? int size = 3; int array[size] = {1, 2, 3};? All of the mentioned
An array of similar data types which themselves are a collection of dissimilar data type are ___________
? Linked Lists? Trees? Array of Structure? All of the mentioned
Comment on an array of the void data type.
? It can store any data-type? It only stores element of similar data type to first element? It acquires the data type with the highest precision in it? You cannot have an array of void data type
What will be the output of the following C code? #include <stdio.h> int main() { int ary[4] = {1, 2, 3, 4}; int p[4]; p = ary; printf("%d\n", p[1]); }
? 1? Compile time error? Undefined behaviour? 2