0% found this document useful (0 votes)
31 views

C Test

The document contains 10 questions about C programming concepts like operators, data types, and function calls. Each question is multiple choice with 4 possible answers. The questions test knowledge of precedence, side effects, return values, and output from sample code snippets.

Uploaded by

nagpalakshit99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

C Test

The document contains 10 questions about C programming concepts like operators, data types, and function calls. Each question is multiple choice with 4 possible answers. The questions test knowledge of precedence, side effects, return values, and output from sample code snippets.

Uploaded by

nagpalakshit99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Question 1

#include "stdio.h"

int main()

int x, y = 5, z = 5;

x = y == z;

printf("%d", x);

getchar();

return 0;

A 0

B 1

C 5

D Compiler Error

Question 2

#include <stdio.h>

int main()

int i = 1, 2, 3;

printf("%d", i);

return 0;

}
A 1

B 3

C Garbage value

D Compile time error

Question 3

#include <stdio.h>

int main()

int i = (1, 2, 3);

printf("%d", i);

return 0;

A 1

B 3

C Garbage value

D Compile time error

Question 4

#include <stdio.h>
int main()

int i;

i = 1, 2, 3;

printf("%d", i);

return 0;

A 1

B 3

C Garbage value

D Compile time error

Question 5

#include <stdio.h>

int main()

int i = 3;

printf("%d", (++i)++);

return 0;

Run on IDE

What is the output of the above program?

A 3

B 4
C 5

D Compile-time error

Question 6

What is the output of below program?

#include <stdio.h>

int foo(int* a, int* b)

int sum = *a + *b;

*b = *a;

return *a = sum - *b;

int main()

int i = 0, j = 1, k = 2, l;

l = i++ || foo(&j, &k);

printf("%d %d %d %d", i, j, k, l);

return 0;

A 1211

B 1121

C1221

D 1222
Question 7

#include <stdio.h>

int main()

int i = 5, j = 10, k = 15;

printf("%d ", sizeof(k /= i + j));

printf("%d", k);

return 0;

Assume size of an integer as 4 bytes. What is the output of above program?

A 41

B 415

C 21

D Compile-time error

Question 8

#include <stdio.h>

int main()

//Assume sizeof character is 1 byte and sizeof integer is 4 bytes

printf("%d", sizeof(printf("GeeksQuiz")));

return 0;

A GeeksQuiz4
B 4GeeksQuiz

C GeeksQuiz9

D 4

E Compile-time error

Question 9

Output of following program?

#include <stdio.h>

int f1() { printf ("Geeks"); return 1;}

int f2() { printf ("Quiz"); return 1;}

int main()

int p = f1() + f2();

return 0;

A GeeksQuiz

B QuizGeeks

C Compiler Dependent

D Compiler Error

Question 10

What is the output of following program?

#include <stdio.h>
int main()

int a = 1;

int b = 1;

int c = a || --b;

int d = a-- && --b;

printf("a = %d, b = %d, c = %d, d = %d", a, b, c, d);

return 0;

A a = 0, b = 1, c = 1, d = 0

B a = 0, b = 0, c = 1, d = 0

C a = 1, b = 1, c = 1, d = 1

D a = 0, b = 0, c = 0, d = 0

You might also like