C Language MCQ Exam Trivia! Quiz

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Abhinav Pandey
A
Abhinav Pandey
Community Contributor
Quizzes Created: 1 | Total Attempts: 193
Questions: 15 | Attempts: 193

SettingsSettingsSettings
C Language MCQ Exam Trivia! Quiz - Quiz

.


Questions and Answers
  • 1. 

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

    • A.

      Int a3;

    • B.

      Int 3_a;

    • C.

      Int _3a

    • D.

      Int a_3;

    Correct Answer
    B. Int 3_a;
    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.

    Rate this question:

  • 2. 

    All keywords in C are in?

    • A.

      Camel Case letters

    • B.

      Upper Case letters

    • C.

      Lower Case letters

    • D.

      None

    Correct Answer
    C. Lower Case letters
    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.

    Rate this question:

  • 3. 

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

    • A.

      Compile time error

    • B.

      -1

    • C.

      1

    • D.

      None

    Correct Answer
    B. -1
    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.

    Rate this question:

  • 4. 

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

    • A.

      6.75

    • B.

      1.85

    • C.

      19

    • D.

      3

    Correct Answer
    C. 19
    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.

    Rate this question:

  • 5. 

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

    • A.

      10,10

    • B.

      11,10

    • C.

      10,11

    • D.

      11,11

    Correct Answer
    D. 11,11
    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.

    Rate this question:

  • 6. 

    What is the size of an int data type?

    • A.

      8 Bytes

    • B.

      4 Bytes

    • C.

      Depends on the system/compiler

    • D.

      Cannot be determined.

    Correct Answer
    C. Depends on the system/compiler
    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.

    Rate this question:

  • 7. 

    What is short int in C programming?

    • A.

      Basic data type of C

    • B.

      Qualifier

    • C.

      Short is the qualifier and int is the basic datatype

    • D.

      All of the mentioned.

    Correct Answer
    C. Short is the qualifier and int is the basic datatype
    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.

    Rate this question:

  • 8. 

    Which of the datatypes have a size that is variable?

    • A.

      Double

    • B.

      Int

    • C.

      Struct

    • D.

      Float

    Correct Answer
    C. Struct
    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.

    Rate this question:

  • 9. 

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

    • A.

      Compile time error

    • B.

      Whatever character getchar function returns

    • C.

      Ascii value of character getchar function returns

    • D.

      2

    Correct Answer
    C. Ascii value of character getchar function returns
    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().

    Rate this question:

  • 10. 

    #include is called

    • A.

      Preprocessor directive

    • B.

      File inclusion directive

    • C.

      Inclusion directive

    • D.

       None of the mentioned

    Correct Answer
    A. Preprocessor directive
    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.

    Rate this question:

  • 11. 

    C preprocessors can have compiler-specific features.

    • A.

      True

    • B.

      False

    • C.

      Depends on the standard

    • D.

      Depends on the platform

    Correct Answer
    A. True
    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.

    Rate this question:

  • 12. 

    Which of the following are C preprocessors?

    • A.

      #ifdef

    • B.

      #define

    • C.

      #endif

    • D.

      All of the mentioned.

    Correct Answer
    D. All of the mentioned.
    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.

    Rate this question:

  • 13. 

    #include statement must be written:

    • A.

      Before main()

    • B.

      After main()

    • C.

      Before any scanf/printf

    • D.

      It can be written anywhere

    Correct Answer
    C. Before any scanf/printf
    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.

    Rate this question:

  • 14. 

    The C-preprocessors are specified with _________symbol.

    • A.

      #

    • B.

      $

    • C.

      " "

    • D.

      None of the mentioned

    Correct Answer
    A. #
    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.

    Rate this question:

  • 15. 

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

    • A.

      Yes

    • B.

      No

    • C.

      Depends on the C standard implemented by compilers

    • D.

      None of the mentioned

    Correct Answer
    A. Yes
    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.

    Rate this question:

Quiz Review Timeline +

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
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.