C

1. Comment on the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int const k = 5;
  5.         k++;
  6.         printf("k is %d", k);
  7.     }
a) k is 6
b) Error due to const succeeding int
c) Error, because a constant variable can be changed only twice
d) Error, because a constant variable cannot be changed
2. What is the output of this C code?
  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int a = 2 + 3 - 4 + 8 -  5 % 4;
  5.         printf("%d\n", a);
  6.     }
a) 0
b) 8
c) 11
d) 9
3. Which of the following is an invalid assignment operator?
a) a %= 10;
b) a /= 10;
c) a |= 10;
d) None of the mentioned
4. #pragma exit is primarily used for?
a) Checking memory leaks after exitting the program
b) Informing Operating System that program has terminated
c) Running a function at exitting the program
d) No such preprocessor exist
5. What is the scope of a function?
a) Whole source file in which it is defined
b) From the point of declaration to the end of the file in which it is defined
c) Any source file in a program
d) From the point of declaration to the end of the file being compiled

6. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         int x[2];
  5.     };
  6.     struct q
  7.     {
  8.         int *x;
  9.     };
  10.     int main()
  11.     {
  12.         struct p p1 = {1, 2};
  13.         struct q *ptr1;
  14.         ptr1->x = (struct q*)&p1.x;
  15.         printf("%d\n", ptr1->x[1]);
  16.     }
a) Compile time error
b) Segmentation fault/code crash
c) 2
d)0
7. Which loop is most suitable to first perform the operation and then test the condition?
a) for loop
b) while loop
c) do-while loop
d) none of the mentioned

8. What is the output of this C code?

  1.  #include <stdio.h>
  2.     int foo(int, int);
  3.     #define foo(x, y) x / y + x
  4.     int main()
  5.     {
  6.         int i = -6, j = 3;
  7.         printf("%d ",foo(i + j, 3));
  8.         #undef foo
  9.         printf("%d\n",foo(i + j, 3));
  10.     }
  11.     int foo(int x, int y)
  12.     {
  13.         return x / y + x;
  14.     }
a) -8 -4
b) Compile time error
c) -8 -8
d) Undefined behaviour
9. Which of the following properties of #define not true?
a) You can use a pointer to #define
b) #define can be made externally available
c) They obey scope rules
d) All of the mentioned
10. Which of the following mathematical function requires 2 parameter for successful function call?
a) fmod();
b) div();
c) atan2();
d) all of the mentioned
0
{"name":"C", "url":"https://www.quiz-maker.com/QBGO5VL","txt":"1. Comment on the output of this C code? #include void main() { int const k = 5; k++; printf(\"k is %d\", k); }, 2. What is the output of this C code? #include void main() { int a = 2 + 3 - 4 + 8 - 5 % 4; printf(\"%d\\n\", a); }, 3. Which of the following is an invalid assignment operator?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker