Pointers
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int *ptr1 = (int *)4;
int *ptr2 = (int *)6;
printf("%d", ptr1 + ptr2);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Compilation Error
main.c: In function ‘main’:
main.c:6:27: error: invalid operands to binary + (have ‘int *’ and ‘int *’)
printf("%d", ptr1 + ptr2);
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
double *p = (double *)150;
p = p + 5;
printf("%u", p);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
190
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int num[5] = {11, 21, 31, 41, 51};
int ptr[5];
ptr = num;
printf("%d\n", ptr[2]);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Compilation Error
main.c: In function ‘main’:
main.c:6:13: error: assignment to expression with array type
ptr = num;
- Comment on an array of the void data type.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
You cannot have an array of void data type
- An array of similar data types which themselves are a collection of dissimilar data type are ___________.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Array of Structure