C

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, fun
ctions, and operators - Great for honing your programming skills
1. Comment on the output of this C code?
-
#include <stdio.h>
-
void main()
-
{
-
int const k = 5;
-
k++;
-
printf("k is %d", k);
-
}
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?
-
#include <stdio.h>
-
void main()
-
{
-
int a = 2 + 3 - 4 + 8 - 5 % 4;
-
printf("%d\n", a);
-
}
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?
-
#include <stdio.h>
-
struct p
-
{
-
int x[2];
-
};
-
struct q
-
{
-
int *x;
-
};
-
int main()
-
{
-
struct p p1 = {1, 2};
-
struct q *ptr1;
-
ptr1->x = (struct q*)&p1.x;
-
printf("%d\n", ptr1->x[1]);
-
}
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?
-
#include <stdio.h>
-
int foo(int, int);
-
#define foo(x, y) x / y + x
-
int main()
-
{
-
int I = -6, j = 3;
-
printf("%d ",foo(i + j, 3));
-
#undef foo
-
printf("%d\n",foo(i + j, 3));
-
}
-
int foo(int x, int y)
-
{
-
return x / y + x;
-
}
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"}
More Surveys
Programming Background Knowledge
6317
Entity Relationship Lecture
10536
9-Basic Programming
331623
Quiz Poll, Lecture 1
8467
Is extra python training needed/wanted?
6318
Mivane
8417
Computer Science
6347
Subject Preferences
3229
C++ Genesis IEEE ECU
1269
Tech-Cult : The CSEian's Club
4250
HTML Readiness Quiz
3260
Video Game Development Club Team Interests After Workshops
9416