C Language MCQ Exam Trivia! Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Abhinav Pandey
A
Abhinav Pandey
Community Contributor
Quizzes Created: 1 | Total Attempts: 535
| Attempts: 535 | Questions: 15
Please wait...
Question 1 / 15
0 %
0/100
Score 0/100
1. The C-preprocessors are specified with _________symbol.

Explanation

The C-preprocessors are specified with the # symbol. This symbol is used to indicate that the following line is a preprocessor directive, which is a command that is processed before the code is compiled. Preprocessor directives are used to include header files, define macros, and perform other tasks that are necessary for the compilation process.

Submit
Please wait...
About This Quiz
C Language MCQ Exam Trivia! Quiz - Quiz

Dive into the intricacies of C programming with this engaging MCQ Exam Trivia! Quiz. Test your knowledge on variable declarations, operators, pointers, and data types. Perfect for learners... see morelooking to sharpen their programming skills and understand core concepts in C. see less

2. All keywords in C are in?

Explanation

In the C programming language, all keywords are written in lower case letters. This is a standard convention followed in C programming to differentiate keywords from user-defined identifiers. Using lower case letters for keywords helps in maintaining code readability and consistency.

Submit
3. What is the value of x in this C code? void main()     {         int x = 4 *5 / 2 + 9;     }

Explanation

The value of x in the given C code is 19. This is because the expression "4 * 5 / 2 + 9" is evaluated from left to right according to the order of operations. First, the multiplication "4 * 5" is performed, resulting in 20. Then, the division "20 / 2" is performed, resulting in 10. Finally, the addition "10 + 9" is performed, resulting in 19.

Submit
4. Which of the datatypes have a size that is variable?

Explanation

Struct is a datatype that allows the grouping of different variables under one name, creating a composite data type. Unlike other datatypes like double, int, and float, the size of a struct is variable and depends on the size of its individual members. This means that the size of a struct can be different based on the types and sizes of its members, making it a datatype with variable size.

Submit
5. #include is called

Explanation

The given correct answer is "Preprocessor directive" because the #include statement is a preprocessor directive in C and C++ programming languages. It is used to include the content of another file in the current file during the compilation process. The preprocessor scans the source code before the actual compilation and replaces the #include statement with the content of the specified file. This allows for code reuse and modular programming by including header files that contain function prototypes, definitions, and other necessary declarations.

Submit
6. Which of the following are C preprocessors?

Explanation

The given answer is "All of the mentioned." This means that all of the options listed (#ifdef, #define, #endif) are C preprocessors. C preprocessors are directives that are processed by the C preprocessor before the compilation of the code. #ifdef is used to check if a macro is defined, #define is used to define a macro, and #endif is used to end a conditional block. Therefore, all of these options are valid C preprocessors.

Submit
7. Does this compile without error? int main() { for (int k = 0; k < 10; k++); return 0; }

Explanation

The given code will compile without error. The code defines a main function and uses a for loop to iterate from 0 to 9. The loop body is empty, indicated by the semicolon immediately following the closing parenthesis of the for loop. After the loop, the code returns 0. Since there are no syntax errors or logical issues in the code, it will compile successfully without any errors.

Submit
8. What is the output of this C code? int main() { int x = 1; int y = x == 1 ? getchar(): 2; printf("%d\n", y); }

Explanation

The code initializes the variable x to 1. It then uses the ternary operator to check if x is equal to 1. Since it is true, the code executes the getchar() function, which reads a character from the user. The getchar() function returns the ASCII value of the character. Therefore, the output of the code will be the ASCII value of the character read by getchar().

Submit
9. What is the output of this C code?      int main()     {         int i = -5;         int k = i %4;         printf("%d\n", k);     }  

Explanation

The code snippet declares two integer variables, i and k. The value of i is initialized to -5. The value of k is assigned the result of i modulo 4, which is -1. The printf statement then prints the value of k, which is -1. Therefore, the output of this C code is -1.

Submit
10. What is the output of this C code? int main() { int *ptr, a = 10; ptr = &a; *ptr += 1; printf("%d,%d/n", *ptr, a); }

Explanation

The code declares a pointer variable 'ptr' and an integer variable 'a' with a value of 10. 'ptr' is then assigned the address of 'a'. The line '*ptr += 1' increments the value at the memory location pointed to by 'ptr' by 1, which means 'a' is also incremented by 1. The printf statement prints the value at the memory location pointed to by 'ptr' (which is now 11) and the value of 'a' (which is also 11). Therefore, the output of the code is 11,11.

Submit
11. Which of the following is not a valid variable name declaration?

Explanation

The variable name "3_a" is not a valid declaration because it starts with a number. In programming, variable names cannot begin with a number, they must start with a letter or an underscore.

Submit
12. C preprocessors can have compiler-specific features.

Explanation

C preprocessors can have compiler-specific features because the preprocessor directives in C are evaluated by the compiler before the actual compilation process begins. This allows the preprocessor to have knowledge of the specific features and extensions provided by the compiler. Therefore, different compilers may have their own unique set of preprocessor features and behaviors, making it possible for C preprocessors to have compiler-specific features.

Submit
13. What is short int in C programming?

Explanation

In C programming, a short int is a data type that is a combination of a qualifier and a basic data type. The "short" is the qualifier, indicating that the variable will take up less memory than a regular int. The "int" is the basic data type, specifying that the variable will store integer values. Therefore, the correct answer is that short is the qualifier and int is the basic data type.

Submit
14. What is the size of an int data type?

Explanation

The size of an int data type depends on the system/compiler. Different systems and compilers may have different sizes for the int data type. Therefore, the size cannot be determined without knowing the specific system/compiler being used.

Submit
15. #include statement must be written:

Explanation

The #include statement must be written before any scanf/printf because it is used to include header files in the program. Header files contain important function declarations and definitions that are needed for the program to compile and run correctly. Therefore, the #include statement should be placed at the beginning of the program, before any functions or statements that rely on the functions declared in the header files.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 21, 2020
    Quiz Created by
    Abhinav Pandey
Cancel
  • All
    All (15)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
The C-preprocessors are specified with _________symbol.
All keywords in C are in?
What is the value of x in this C code?...
Which of the datatypes have a size that is variable?
#include is called
Which of the following are C preprocessors?
Does this compile without error?...
What is the output of this C code?...
What is the output of this C code?...
What is the output of this C code?...
Which of the following is not a valid variable name declaration?
C preprocessors can have compiler-specific features.
What is short int in C programming?
What is the size of an int data type?
#include statement must be written:
Alert!

Advertisement