C Programming Quiz: Test Your Knowledge Quiz

  1. Question 1

    What type of programming language is C considered?

    1. A. Object-oriented
    2. B. Functional
    3. C. General-purpose, procedural
    4. D. Logic-based
    5. E. C is a markup language
  2. Question 2

    What is the entry point of a C program?

    1. A. start()
    2. B. begin()
    3. C. program()
    4. D. main()
    5. E. entry()
  3. Question 3

    Which header file is required for input and output operations in C?

    1. A. iostream.h
    2. B. stdio.h
    3. C. conio.h
    4. D. stdlib.h
    5. E. io.h
  4. Question 4

    What is the size of the char data type in C?

    1. A. 2 bytes
    2. B. 4 bytes
    3. C. 8 bytes
    4. D. 1 byte
    5. E. Variable depending on the system
  5. Question 5

    What is the main difference between the '=' and '==' operators in C?

    1. A. They are interchangeable
    2. B. '=' is for comparison, '==' is for assignment
    3. C. '=' is for assignment, '==' is for comparison
    4. D. '=' is used for strings, '==' is used for numbers
    5. E. There is no difference
  6. Question 6

    Which type of loop guarantees at least one execution of the loop body?

    1. A. for loop
    2. B. while loop
    3. C. do-while loop
    4. D. if loop
    5. E. repeat loop
  7. Question 7

    What is the purpose of the `scanf` function in C?

    1. A. To print output to the console
    2. B. To read input from the user
    3. C. To perform mathematical calculations
    4. D. To define variables
    5. E. To exit the program
  8. Question 8

    How can you swap the values of two variables in C without using a third variable?

    1. A. Using the swap() function
    2. B. Using bitwise XOR operator
    3. C. Using pointer arithmetic
    4. D. Using addition and subtraction
    5. E. It's not possible
  9. Question 9

    What is the main difference between malloc() and calloc()?

    1. A. malloc() initializes memory to zero, calloc() does not
    2. B. calloc() initializes memory to zero, malloc() does not
    3. C. malloc() is for arrays, calloc() is for single variables
    4. D. calloc() is faster than malloc()
    5. E. There is no difference
  10. Question 10

    Which function is used to determine the length of a string in C?

    1. A. stringlength()
    2. B. len()
    3. C. strsize()
    4. D. strlen()
    5. E. size()
  11. Question 11

    What is recursion in C?

    1. A. A loop that runs indefinitely
    2. B. A function that calls itself
    3. C. A variable that stores multiple values
    4. D. A way to define constants
    5. E. A function that doesn't return a value
  12. Question 12

    What is a prime number?

    1. A. A number divisible by 2
    2. B. A number that can only be divided by 1 and itself
    3. C. A number that is a perfect square
    4. D. A number that is even
    5. E. Any integer
  13. Question 13

    Which function is used to open a file in C?

    1. A. fileopen()
    2. B. openfile()
    3. C. fopen()
    4. D. createfile()
    5. E. open()
  14. Question 14

    What does 'undefined behavior' in C mean?

    1. A. The program will always crash
    2. B. The behavior is predictable and well-defined
    3. C. The behavior is unpredictable and not defined by the C standard
    4. D. The program will run without errors
    5. E. The program will compile with warnings
  15. Question 15

    What is a stack in the context of data structures?

    1. A. A linear data structure following FIFO principle
    2. B. A circular data structure
    3. C. A linear data structure following LIFO principle
    4. D. A non-linear data structure
    5. E. A way to store data in the cloud