C

A colorful and engaging illustration of programming concepts, featuring the C programming language, code snippets, and symbols related to coding and algorithms, in a modern digital style.

C Programming Quiz

Test your knowledge of C programming with this engaging quiz! Designed for students, teachers, and programming enthusiasts, this quiz covers a wide range of topics related to the C language.

  • 10 challenging questions
  • Assess your understanding of C syntax, functions, and operators
  • Great for honing your programming skills
10 Questions2 MinutesCreated by CodingEagle37

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
{"name":"C", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your knowledge of C programming with this engaging quiz! Designed for students, teachers, and programming enthusiasts, this quiz covers a wide range of topics related to the C language.10 challenging questionsAssess your understanding of C syntax, functions, and operatorsGreat for honing your programming skills","img":"https:/images/course6.png"}
Powered by: Quiz Maker