# include <stdio.h>
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
print(arr);
return 0;
}
A. 12345678
B. 12
C. Compiler error
D. Run time error
2. Consider the following C-function in which a[n] and b[m] are two sorted integer arrays and c[n + m]
be another integer array.
Which of the following condition(s) hold(s) after the termination of the while loop?
: | . . | |
,
[GATE 2006]
[GATE 2003]
#include<stdio.h>
int main()
{
int a[10][20][30] = {0};
a[5][2][1] = 2;
return 0;
}
Which of the following will print the value 2 for the above code?
A. printf("%d",*(((a+5)+2)+1));
B. printf("%d",***((a+5)+2)+1);
C. printf("%d",*(*(*(a+5)+2)+1));
D. None of these
: | . . | |
,
5. Consider a compiler where int takes 4 bytes, char takes 1 byte and pointer takes 4 bytes. What is
the printed by the following program
#include <stdio.h>
int main()
{
int arri[] = {1, 2 ,3};
int *ptri = arri;
return 0;
}
A. sizeof arri[] = 12 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 1
B. sizeof arri[] = 12 sizeof ptri = 8 sizeof arrc[] = 3 sizeof ptrc = 1
C. sizeof arri[] = 3 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 1
D. sizeof arri[] = 12 sizeof ptri = 8 sizeof arrc[] = 3 sizeof ptrc = 8
: | . . | |
,
8. Assume size of an integer and a pointer is 4 byte. What does the following program prints:
#include <stdio.h>
#define R 10
#define C 20
int main()
{
int (*p)[R][C];
printf("%d", sizeof(*p));
getchar();
return 0;
}
A. 200
B. 400
C. 800
D. 1600
9. What does the following program Segment print ?
A. 2 5
B. Garbage value
C. Compiler error
D. Segmentation fault
10. What does the following program prints
#include <stdio.h>
void f(char **p)
{
char *t;
t = (p += sizeof(int))[-1];
printf("%s\n", t);
}
int main()
{
char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" };
f(argv);
return 0;
}
A. gh
B. ij
C. cd
D. ef
: | . . | |
,