QUIZ
QUIZ
a) Steve Jobs
b) James Gosling
c) Dennis Ritchie
d) Rasmus Lerdorf
1. #include <stdio.h>
2. int main()
3. {
4. int i = 5;
5. i = i / 3;
6. printf("%d\n", i);
7. return 0;
8. }
a) Implementation defined
b) 1
c) 3
d) Compile time error
1. #include <stdio.h>
2. int main()
3. {
4. int i = 5;
5. i = i / 3;
6. printf("%d\n", i);
7. return 0;
8. }
a) Implementation defined
b) 1
c) 3
d) Compile time error
1. #include <stdio.h>
2. int main()
3. {
4. int i = -3;
5. int k = i % 2;
6. printf("%d\n", k);
7. }
a) Compile time error
b) -1
c) 1
d) Implementation defined
4.What will be the output of the following C code?
1. #include <stdio.h>
2. int main()
3. {
4. int i = 0;
5. int j = i++ + i;
6. printf("%d\n", j);
7. }
a) 0
b) 1
c) 2
d) Compile time error
1. #include <stdio.h>
2. int main()
3. {
4. int i = 2;
5. int j = ++i + i;
6. printf("%d\n", j);
7. }
a) 6
b) 5
c) 4
d) Compile time error
1. #include <stdio.h>
2. int main()
3. {
4. int a = 1, b = 1, c;
5. c = a++ + b;
6. printf("%d, %d", a, b);
7. }
a) a = 1, b = 1
b) a = 2, b = 1
c) a = 1, b = 2
d) a = 2, b = 2
1. #include <stdio.h>
2. int main()
3. {
4. int y = 10000;
5. int y = 34;
6. printf("Hello World! %d\n", y);
7. return 0;
8. }
1. #include <stdio.h>
2. int main()
3. {
4. int main = 3;
5. printf("%d", main);
6. return 0;
7. }
a) It will cause a compile-time error
b) It will cause a run-time error
c) It will run without any error and prints 3
d) It will experience infinite looping
1. #include <stdio.h>
2. void main()
3. {
4. int x = 5 * 9 / 3 + 9;
5. }
10.What will be the output of the following C code snippet?
1. #include <stdio.h>
2. void main()
3. {
4. 1 < 2 ? return 1: return 2;
5. }
11. What will be the output of the following C code?
1. #include <stdio.h>
2. void main()
3. {
4. int x = 1, z = 3;
5. int y = x << 3;
6. printf(" %d\n", y);
7. }
a) -2147483648
b) -1
c) Run time error
d) 8
12. What will be the output of the following C code?
1. #include <stdio.h>
2. void main()
3. {
4. int x = 0, y = 2, z = 3;
5. int a = x & y | z;
6. printf("%d", a);
7. }
a) 3
b) 0
c) 2
d) Run time error
1.#include <stdio.h>
2. int main()
3. {
4. printf("sanfoundry\rclass\n");
5. return 0;
6. }
a) sanfoundryclass
b) sanfoundry
class
c) classundry
d) sanfoundry
1. #include <stdio.h>
2. int main()
3. {
4. const int p;
5. p = 4;
6. printf("p is %d", p);
7. return 0;
8. }
a) p is 4
b) Compile time error
c) Run time error
d) p is followed by a garbage value
3.
4.
5.
6.