MCQ Related “C” Language

  1. Which of the following is a valid variable name in C?
    • A) 1variable
    • B) variable_1
    • C) variable-1
    • D) variable 1
  2. What is the output of the following code?
    printf("%d", 5 + 2 * 3);
    • A) 21
    • B) 11
    • C) 16
    • D) 17
  3. Which data type does not allow decimal points?
    • A) float
    • B) double
    • C) int
    • D) char
  4. What is the use of the break statement in C?
    • A) To terminate a loop
    • B) To skip to the next iteration
    • C) To exit a function
    • D) To pause execution
  5. Which operator is used to access the value of a variable using a pointer?
    • A) *
    • B) &
    • C) %
    • D) #
  6. What is the correct syntax to include a header file in C?
    • A) import <stdio.h>
    • B) include <stdio.h>
    • C) #include <stdio.h>
    • D) #import <stdio.h>
  7. What will be the size of an integer variable on a 32-bit system?
    • A) 2 bytes
    • B) 4 bytes
    • C) 8 bytes
    • D) Depend on the compiler
  8. Which loop is guaranteed to execute at least once?
    • A) for loop
    • B) while loop
    • C) do-while loop
    • D) none of the above
  9. Which of the following is a correct way to declare a pointer?
    • A) int *ptr;
    • B) pointer int ptr;
    • C) int &ptr;
    • D) int ptr*;
  10. What will the following code output?
    for(int i = 0; i < 5; i++) {
    printf("%d ", i);
    }
    • A) 1 2 3 4 5
    • B) 0 1 2 3 4
    • C) 0 1 2 3 4 5
    • D) 1 2 3 4
  11. What does NULL represent in C?
    • A) A pointer to a variable
    • B) A null character
    • C) A pointer that does not point to any valid memory
    • D) An uninitialized variable
  12. Which of the following is not a valid control structure in C?
    • A) if-else
    • B) switch
    • C) select
    • D) for
  13. What is the purpose of the sizeof operator?
    • A) To determine the size of a variable
    • B) To allocate memory dynamically
    • C) To initialize variables
    • D) To convert data types
  14. Which of the following function prototypes is correct?
    • A) void function(int);
    • B) void function(int);
    • C) int function(void);
    • D) All of the above
  15. Which of these is the correct method to declare an array of integers?
    • A) int array[];
    • B) int array[10];
    • C) int array(10);
    • D) array int[10];
  16. What is the output of the following code?
    int x = 5;
    printf("%d", x++);
    • A) 6
    • B) 5
    • C) 4
    • D) 0
  17. Which of the following is a valid way to comment in C?
    • A) // comment
    • B) /* comment */
    • C) # comment
    • D) Both A and B
  18. How do you declare a constant in C?
    • A) constant int x = 10;
    • B) const int x = 10;
    • C) #define x 10
    • D) Both B and C
  19. What is the result of the expression 5 & 3?
    • A) 0
    • B) 1
    • C) 5
    • D) 3
  20. Which operator is used for logical AND in C?
    • A) &
    • B) &&
    • C) |
    • D) ||
  21. What will the output be of the following code?
    printf("%c", 'A' + 1);
    • A) A
    • B) B
    • C) C
    • D) 66
  22. Which library function is used to find the length of a string in C?
    • A) strlength()
    • B) strlen()
    • C) length()
    • D) size()
  23. Which of the following is a standard input/output library in C?
    • A) stdlib.h
    • B) conio.h
    • C) stdio.h
    • D) string.h
  24. What will be the result of printf("%d", 10/3);?
    • A) 3
    • B) 3.33
    • C) 3.0
    • D) 10
  25. In C, how do you declare a function that takes no parameters?
    • A) void function();
    • B) void function(void);
    • C) Both A and B
    • D) None of the above
  26. What is the default return type of a function in C?
    • A) void
    • B) int
    • C) float
    • D) char
  27. What is the output of the following code?
    int a = 5;
    int b = 10;
    printf("%d", a > b ? a : b);
    • A) 5
    • B) 10
    • C) 0
    • D) -1
  28. How are strings represented in C?
    • A) Char arrays
    • B) Int arrays
    • C) Float arrays
    • D) Pointer to char
  29. What will sizeof(char) return?
    • A) 1
    • B) 2
    • C) 4
    • D) 8
  30. Which directive is used to define macros in C?
    • A) #macro
    • B) #define
    • C) #constants
    • D) #include
  31. What is the purpose of the return statement in a function?
    • A) To stop the function execution
    • B) To return a value to the caller
    • C) Both A and B
    • D) To call another function
  32. Which of the following is used to read formatted input from the standard input in C?
    • A) printf()
    • B) scanf()
    • C) gets()
    • D) fgetc()
  33. What will the result of 5 % 2 be?
    • A) 1
    • B) 2
    • C) 5
    • D) 0
  34. What does the following code do?
    int x = 1;
    x = x << 2;
    • A) Shifts x left by 2 bits
    • B) Shifts x right by 2 bits
    • C) Multiplies x by 4
    • D) Both A and C
  35. How do you declare a multidimensional array?
    • A) int array[][];
    • B) int array[10][10];
    • C) array int[10][10];
    • D) int array[10,10];
  36. What will the following code output?
    int a = 5, b = 10;
    printf("%d", a & b);
    • A) 15
    • B) 0
    • C) 5
    • D) 10
  37. Which of the following is not a looping statement?
    • A) for
    • B) while
    • C) do-while
    • D) switch
  38. In C, what is the value of sizeof(int) on a 64-bit system?
    • A) 2
    • B) 4
    • C) 8
    • D) 16
  39. Which function is used to convert a string to an integer in C?
    • A) atoi()
    • B) itoa()
    • C) strtoint()
    • D) inttos()
  40. What is the purpose of #include <stdlib.h>?
    • A) To use input/output functions
    • B) To perform memory allocation
    • C) To use string manipulation functions
    • D) To perform mathematical computations
  41. How do you access the last element of an array named arr?
    • A) arr[length(arr) – 1]
    • B) arr[length – 1]
    • C) arr[size – 1]
    • D) arr[size(arr) – 1]
  42. What operator is used for incrementing a variable by one?
    • A) ++
    • B) —
    • C) +
    • D) +=
  43. What is the purpose of the #define directive?
    • A) To define a function
    • B) To create macros
    • C) To allocate memory
    • D) To include files
  44. Which of the following functions can be used to free dynamically allocated memory?
    • A) free()
    • B) delete()
    • C) realloc()
    • D) malloc()
  45. In C, which of the following can be a valid return value for a function declared as void?
    • A) return 0;
    • B) return 1;
    • C) return NULL;
    • D) None of the above
  46. Which C standard library function is used to compare two strings?
    • A) stringcmp()
    • B) strcmp()
    • C) strcompare()
    • D) strcomp()
  47. What is the output of the following expression?
    printf("%d", (1 + 2) * (3 + 4));
    • A) 21
    • B) 7
    • C) 19
    • D) 28
  48. In an array declaration, what does the number in brackets represent?
    • A) The maximum size of the array
    • B) The minimum size of the array
    • C) The initial value of the array
    • D) A reserved space in memory
  49. Which of the following is true about a null pointer?
    • A) It stores a valid memory address.
    • B) It can be dereferenced.
    • C) It points to undefined memory.
    • D) It is an address that points to nothing.
  50. In the context of C programming, what does printf stand for?
    • A) Print format
    • B) Print file
    • C) Print function
    • D) Print format variable