C Certification Sample Questions (For Students)
C Certification Sample Questions (For Students)
int main()
int x = 5;
return 0;
int main()
if (a = b) printf("Equal");
return 0;
int main()
{
f
f
f
int i = 0;
while (i < 5) {
if (i == 3) break;
i++;
return 0;
printf("%d", sizeof(3.14f));
int main()
str[0] = 'h';
printf("%s", str);
return 0;
int main() {
int x = 5, y = 10;
x ^= y ^= x ^= y;
return 0;
int i = 5;
i = i++ + ++i;
18. Fill in the blank:
The ________ directive is used to include a header ile.
int main() {
int a = 0;
if (a = 0) printf("Zero");
else printf("Non-zero");
return 0;
22. Which of the following is not a correct way to pass an array to a function?
a) func(int arr[])
b) func(int *arr)
c) func(int arr[5])
d) func(int arr)
int main() {
printf("%d", *ptr);
f
return 0;
int main() {
printf("%d", arr[3]);
return 0;
int main() {
int a = 5, b = 10;
int *p = &a;
*p = b;
printf("%d", a);
return 0;
int main() {
}
f
32. What is wrong with this code?
int main() {
int *p;
*p = 10;
printf("%d", *p);
return 0;
int main() {
printf("%d", a[a[1]]);
int main() {
int x = 5;
int *p = &x;
printf("%d", ++*p);
int main() {
printf("%d", arr[2]);
int main() {
int *p = malloc(sizeof(int));
f
*p = 10;
free(p);
printf("%d", *p);
int main() {
int a = 5, b = 10;
swap(&a, &b);
int main() {
printf("%d", strlen("Hello\n"));
int main() {
printf("%d", s2.x);
int main() {
u.a = 65;
printf("%c", u.b);
int main() {
enum { A, B = 5, C } e;
printf("%d", C);
48. Which of the following is not a valid way to pass a structure to a function?
a) Pass by value
b) Pass by reference
c) Pass by pointer
d) Pass by address
int main() {
printf("%d", sizeof(str));
}
50. Which of the following is not a valid bitwise operator?
a) &
b) |
c) ^
d) &&
int main() {
int main() {
char *str;
strcpy(str, "Hello");
printf("%s", str);
int main() {
printf("%d", sizeof("A\0B"));
int main() {
str = "Hello";
printf("%s", str);
printf("%d", sizeof(s));
int main() {
enum { A = 1, B, C = 0 } e;
int main() {
int *p = malloc(sizeof(int));
*p = 5;
free(p);
printf("%d", *p);
int main() {
fprintf(fp, "Hello");
fclose(fp);
fp = fopen("test.txt", "r");
f
char ch = fgetc(fp);
printf("%c", ch);
int main() {
int main() {
printf("%s", __FILE__);
int main() {
#ifdef DEBUG
printf("Debug");
#else
f
f
f
printf("Release");
#endif
int main() {
fputs("Hello", fp);
fclose(fp);
fp = fopen("test.txt", "r");
char str[10];
fgets(str, 3, fp);
printf("%s", str);
int main() {
FILE *fp;
fp = fopen("test.txt", "r");
char ch = fgetc(fp);
printf("%c", ch);
int main() {
printf("%d", __LINE__);
char ch = fgetc(fp);
printf("%c", ch);
int main() {
int main() {
int main() {
int a = 5;
#if a == 5
printf("Five");
#else
printf("Not Five");
#endif
int main() {
printf("%d", sizeof(void));
f
f
}
Additional Questions
83. Which of the following is not a valid format speci ier in printf?
a) %d
b) %f
c) %c
d) %e
e) %s
f) %p
g) %b
int main() {
int x = 5;
printf("%d", x = x + 1);
int main() {
const int x = 5;
x = 10;
printf("%d", x);
int x = 5;
printf("%d", sizeof(x++));
printf("%d", x);
int main() {
int x = 5;
if (x == 5);
printf("Five");
int main() {
int x = 0;
if (x = 0) printf("Zero");
else printf("Non-zero");
int main() {
printf("%d", 1 + 2 * 3 / 4);
int main() {
int x = 5, y = 10;
printf("%d", x + y);
}
100.Predict the output:
int main() { printf("%d", 1 ? 0 ? 5 : 3 : 8); }
int main() {
int main() {
int x = 5;
int *p = &x;
printf("%d", ++*p);
int main() {
printf("%d", 2[arr]);
int main() {
int a = 5, b = 10;
int *p = &a;
*p = b;
printf("%d", a);
int main() {
int main() {
int *p;
*p = 10;
printf("%d", *p);
int main() {
int main() {
int *p = malloc(sizeof(int));
*p = 10;
free(p);
printf("%d", *p);
int main() {
int x = 5;
int *p = &x;
printf("%d", ++*p);
int main() {
printf("%d", arr[2]);
int main() {
int a = 5, b = 10;
swap(&a, &b);
printf("%d", strlen("Hello\n"));
int main() {
printf("%d", s2.x);
int main() {
printf("%c", u.b);
int main() {
enum { A, B = 5, C } e;
printf("%d", C);
int main() {
printf("%d", sizeof(str));
int main() {
int main() {
char *str;
strcpy(str, "Hello");
printf("%s", str);
int main() {
printf("%d", sizeof("A\0B"));
int main() {
str = "Hello";
printf("%s", str);
int main() {
printf("%d", sizeof(s));
int main() {
enum { A = 1, B, C = 0 } e;
int *p = malloc(sizeof(int));
*p = 5;
free(p);
printf("%d", *p);
int main() {
int main() {
fprintf(fp, "Hello");
fclose(fp);
f
f
f
f
f
f
f
f
f
fp = fopen("test.txt", "r");
char ch = fgetc(fp);
printf("%c", ch);
int main() {
int main() {
printf("%s", __FILE__);
int main() {
#ifdef DEBUG
printf("Debug");
f
f
f
#else
printf("Release");
#endif