C Paper
C Paper
C Paper
Arithmetic operator
2. int main()
3. {
4. int i = -3;
5. int k = i % 2;
6. printf("%d\n", k);
7. }
2. int main()
3. {
4. int i = 3;
5. int l = i / -2;
6. int k = i % -2;
8. return 0;
9. }
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
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
5. What will be the final value of x in the following C code?
1. #include <stdio.h>
2. void main()
3. {
4. int x = 5 * 9 / 3 + 9;
5. }
a) 3.75
b) Depends on compiler
c) 24
d) 3
2. void main()
3. {
4. int x = 5.3 % 2;
6. }
a) Value of x is 2.3
b) Value of x is 1
c) Value of x is 0.3
d) Compile time error
7. What will be the output of the following C code?
1. #include <stdio.h>
2. void main()
3. {
4. int y = 3;
5. int x = 5 % 2 * 3 / 2;
7. }
a) Value of x is 1
b) Value of x is 2
c) Value of x is 3
d) Compile time error
Bitwise Operator
2. int main()
3. {
4. int c = 2 ^ 3;
5. printf("%d\n", c);
6. }
a) 1
b) 8
c) 9
d) 0
2. int main()
3. {
5. a = ~a;
6. printf("%d\n", a);
7. }
a) -9
b) -10
c) -11
d) 10
2. int main()
3. {
4. if (7 & 8)
5. printf("Honesty");
8. }
2. int main()
3. {
4. int a = 2;
5. if (a >> 1)
6. printf("%d\n", a);
7. }
a) 0
b) 1
c) 2
d) No Output
2. int main()
3. {
4. int i, n, a = 4;
5. scanf("%d", &n);
7. a = a * 2;
8. }
2. void main()
3. {
4. int x = 97;
5. int y = sizeof(x++);
7. }
a) x is 97
b) x is 98
c) x is 99
d) Run time error
2. void main()
3. {
4. int x = 4, y, z;
5. y = --x;
6. z = x--;
7. printf("%d%d%d", x, y, z);
8. }
a) 3 2 3
b) 2 2 3
c) 3 2 2
d) 2 3 3
2. void main()
3. {
4. int x = 4;
5. int *p = &x;
6. int *k = p++;
7. int r = p - k;
8. printf("%d", r);
9. }
a) 4
b) 8
c) 1
d) Run time error
Declaration
3. int main()
4. {
7. foo(&i);
8. printf("%d", i);
9.
10. }
12. {
13. *i = 20;
14. }
2. int main()
3. {
6. *ptr = 20;
7. printf("%d\n", i);
8. return 0;
9. }
2. int main()
3. {
4. j = 10;
5. printf("%d\n", j++);
6. return 0;
7. }
a) 10
b) 11
c) Compile time error
d) 0
View Answer
4. Will the following C code compile without any error?
1. #include <stdio.h>
2. int main()
3. {
5. return 0;
6. }
a) Yes
b) No
c) Depends on the C standard implemented by compilers
d) None of the mentioned
advertisement
2. int main()
3. {
4. int k;
5. {
6. int k;
8. }
9. }
a) Yes
b) No
c) Depends on the compiler
d) Depends on the C standard implemented by compilers
2. int main()
3. {
5. }
a) %f
b) %d
c) %c
d) %s
2. int main()
3. {
4. int i = 0;
7. return 0;
8. }
a) 0, 2
b) 0, 1
c) 1, 2
d) Undefined
2. What will be the output of the following C code?
1. #include <stdio.h>
2. int main()
3. {
4. int i = 10;
5. int *p = &i;
6. printf("%d\n", *p++);
7. }
a) 10
b) 11
c) Garbage value
d) Address of i
2. void main()
3. {
4. int x = 97;
5. int y = sizeof(x++);
7. }
a) X is 97
b) X is 98
c) X is 99
d) Run time error
4. What will be the output of the following C code?
1. #include <stdio.h>
2. void main()
3. {
4. int x = 4, y, z;
5. y = --x;
6. z = x--;
7. printf("%d%d%d", x, y, z);
8. }
a) 3 2 3
b) 2 3 3
c) 3 2 2
d) 2 3 4
2. void main()
3. {
4. int x = 4;
5. int *p = &x;
6. int *k = p++;
7. int r = p - k;
8. printf("%d", r);
9. }
a) 4
b) 8
c) 1
d) Run time error
2. void main()
3. {
4. int a = 5, b = -7, c = 0, d;
6. printf("\n%d%d%d%d", a, b, c, d);
7. }
a) 6 -6 0 0
b) 6 -5 0 1
c) -6 -6 0 1
d) 6 -6 0 1
2. void main()
3. {
4. int a = -5;
6. printf("%d\n", k);
7. }
a) -4
b) -5
c) 4
d) -3
Data Type
2. int main()
3. {
5. int i;
7. if ((char)a[i] == '5')
8. printf("%d\n", a[i]);
9. else
10. printf("FAIL\n");
11. }
3. Which data type is most suitable for storing a number 65000 in a 32-bit system?
a) signed short
b) unsigned short
c) long
d) int
2. int main()
3. {
5. chr = 128;
6. printf("%d\n", chr);
7. return 0;
8. }
a) 128
b) -128
c) Depends on the compiler
d) None of the mentioned
advertisement
1. #include <stdio.h>
2. int main()
3. {
4. char c;
5. int i = 0;
6. FILE *file;
11. fclose(file);
15. return 0;
16. }
a) a
b) Infinite loop
c) Depends on what fgetc returns
d) Depends on the compiler
View Answer
8. What is short int in C programming?
a) The basic data type of C
b) Qualifier
c) Short is the qualifier and int is the basic data type
d) All of the mentioned