150+ C Programming MCQs

1) C Basics MCQs

1. C language was developed by ___.

  1. Dennis Rechard
  2. Dennis M. Ritchie
  3. Bjarne Stroustrup
  4. Anders Hejlsberg

Answer: B) Dennis M. Ritchie

2. In which year was C language developed?

  1. 1962
  2. 1978
  3. 1979
  4. 1972

Answer: D) 1972

3. C language is a successor to which language?

  1. Basic
  2. Cobol
  3. C++
  4. B

Answer: D) B

4. C is a ___.

  1. Low level language
  2. High level language
  3. Medium level language
  4. None of the above

Answer: C) Medium level language

5. How many keywords are there in C language?

  1. 32
  2. 33
  3. 64
  4. 18

Answer: A) 32

6. C language is a ___.

  1. Procedural oriented programming language
  2. General purpose programming language
  3. Structured programming
  4. All of the above

Answer: D) All of the above

7. Which is not a valid keyword in C language?

  1. for
  2. while
  3. do-while
  4. switch

Answer: C) do-while

8. What is an identifier in C language?

  1. An identifier is a combination of alphanumeric characters used for conditional and control statements
  2. An identifier is a combination of alphanumeric characters used for any variable, function, label name
  3. Both A and B
  4. None of the above

Answer: B) An identifier is a combination of alphanumeric characters used for any variable, function, label name

9. A C-style comment, simply surround the text with ___.

  1. /* and */
  2. // and //
  3. //
  4. /** and **/

Answer: A) /* and */

10. Can we place comments between the statement to comments a part of the code?

  1. Yes
  2. No

Answer: A) Yes

11. ___ is an informal name for ISO/IEC 9899:1999, a past version of the C programming language standard?

  1. C
  2. C++
  3. C89
  4. C99

Answer: D) C99

12. In which version of C language, the C++ Style comment (//) are introduced?

  1. C17
  2. C18
  3. C89
  4. C99

Answer: D) C99

13. The C source file is processed by the ___.

  1. Interpreter
  2. Compiler
  3. Both Interpreter and Compiler
  4. Assembler

Answer: B) Compiler

14. How many whitespace characters are allowed in C language?

  1. 2
  2. 3
  3. 4
  4. 5

Answer: D) 5

15. How many punctuation characters are allowed in C language?

  1. 29
  2. 30
  3. 31
  4. 32

Answer: A) 29

16. What is the extension of a C language source file?

  1. .c
  2. .cpp
  3. .c99
  4. .h

Answer: A) .c

17. What is the extension of a C language header file?

  1. .c
  2. .cpp
  3. .c99
  4. .h

Answer: D) .h

18. To develop which operating, C language was invented?

  1. Linux
  2. Unix
  3. Android
  4. Mac

Answer: B) Unix

19. Does C language support object-oriented approach?

  1. Yes
  2. No

Answer: B) No

20. Which is/are the disadvantage(s) of C language?

  1. No Garbage Collection
  2. Inefficient Memory Management
  3. Low level of abstraction
  4. Lack of Object Orientation
  5. All of the above

Answer: E) All of the above

21. Which are the fundamental data types in C?

  1. char
  2. int
  3. float
  4. All of the above

Answer: D) All of the above

22. How many byte(s) does a char type take in C?

  1. 1
  2. 2
  3. 3
  4. 4

Answer: A) 1

23. For which type, the format specifier “%i” is used?

  1. int
  2. char
  3. float
  4. double

Answer: A) int

24. What is the difference between float and double in C?

  1. both are used for the same purpose
  2. double can store just double value as compare to float value
  3. double is an enhanced version of float and was introduced in C99
  4. double is more precise than float and can store 64 bits

Answer: D) double is more precise than float and can store 64 bits

25. Which is the correct format specifier for double type value in C?

  1. %d
  2. %f
  3. %lf
  4. %LF

Answer: C) %lf

26. The short type represents ___.

  1. int
  2. float
  3. unsigned int
  4. short int

Answer: C) unsigned int

27. How many byte(s) does a short type take in C?

  1. 1
  2. 2
  3. 3
  4. 4

Answer: B) 2

28. What is the correct syntax to declare a variable in C?

  1. data_type variable_name;
  2. data_type as variable_name;
  3. variable_name data_type;
  4. variable_name as data_type;

Answer: A) data_type variable_name;

29. How many types of qualifiers are there in C language?

  1. 2
  2. 3
  3. 4
  4. 5

Answer: B) 3

30. Which is/are the size qualifier(s) in C language?

  1. short
  2. long
  3. double
  4. Both A. and B

Answer: D) Both A. and B.

31. Which is/are the sign qualifier(s) in C language?

  1. signed
  2. unsigned
  3. long
  4. Both A. and B

Answer: D) Both A. and B.

32. Which is/are the type qualifier(s) in C language?

  1. const
  2. volatile
  3. static
  4. Both A. and B

Answer: D) Both A. and B.

33. Which is correct with respect to the size of the data types in C?

  1. char > int > float
  2. char < int < float
  3. int < char < float
  4. int < chat > float

Answer: B) char < int < float

34. Which operator is used to find the remainder of two numbers in C?

  1. /
  2. \
  3. %
  4. //

Answer: C) %

35. Which of the following is not an arithmetic expression?

  1. x = 10
  2. x /= 10
  3. x %= 10
  4. x != 10

Answer: D) x != 10

36. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    int x = 20;
    x %= 3;
    printf("%d",x);
    return 0;
}
  1. 2
  2. 2.5
  3. Error
  4. Warning

Answer: A) 2

37. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    float x = 21.0;
    x %= 3.0;
    printf("%f",x);
    return 0;
}
  1. 7
  2. 7.00
  3. 7.000000
  4. Error

Answer: D) Error

38. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    float x = 23.456;
    printf("%.2f",x);
    return 0;
}
  1. 23.45600
  2. 23.456
  3. 23.45
  4. 23.46

Answer: D) 23.46

39. What will be the output of the following C code?

#include <stdio.h>
void main()
{
    int x = 10;
    int y = x++ + 20;
    printf("%d,%d",x,y);
    return 0;
}
  1. 11,30
  2. 11,31
  3. 10,30
  4. 10,31

Answer: A) 11,30

40. Increment (++) and decrement (–) are the ___ operators in C?

  1. Unary
  2. Binary
  3. Ternary
  4. None of the above

Answer: A) Unary

41. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    unsigned char c=290;
    printf("%d",c);
    return 0;
}
  1. 290
  2. 256
  3. 34
  4. Garbage

Answer: C) 34

42. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    int a=0;
    a=5||2|1;
    printf("%d",a);
    return 0;
}
  1. 1
  2. 7
  3. 0
  4. 8

Answer: A) 1

43. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    int x =-100;
    -100;
    printf("%d",x);
    return 0;
}
  1. 100
  2. -100
  3. 0
  4. Error

Answer: B) -100

44. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    int a,b,c;
    a=0x10; b=010;
    c=a+b;
    printf("%d",c);
    return 0;
}
  1. 20
  2. 24
  3. Garbage
  4. Error

Answer: B) 24

45. Which C keyword is used to extend the visibility of variables?

  1. extend
  2. extends
  3. extern
  4. auto

Answer: C) extern

46. What is the name of “&” operator in C?

  1. Ampersand
  2. And
  3. Address of
  4. None of the above

Answer: C) Address of

47. Which of the following are valid decision-making statements in C?

  1. if
  2. switch
  3. nested if
  4. All of these

Answer: D) All of these

48. Decision making in the C programming language is ___.

  1. Repeating the same statement multiple times
  2. Executing a set of statements based on some condition
  3. Providing a name of the block of code
  4. All of these

Answer: B) Executing a set of statements based on some condition

49. Which of the following is a true value in C programming?

  1. 1
  2. “Progies”
  3. ! NULL
  4. All of these

Answer: D) All of these

50. Ternary operator in C programming is ___.

  1. if-else-if
  2. ? :
  3. ? ; ?
  4. None of these

Answer: B) ? :

51. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    printf((43 > 43) ? "value 1 is greater!" : "value 1 is not greater!");
    return 0;
}
  1. value 1 is not greater
  2. value 1 is greater
  3. Error
  4. None of these

Answer: A) value 1 is not greater

52. What is the correct syntax of if statement in C program?

  1. if(condition){}
  2. if(condition) :
  3. If { [condition] }
  4. None of these

Answer: A)

53. The if statement is a conditional statement?

  1. True
  2. False

Answer: A) True

54. When the condition of if statement is false, the flow of code will ___.

  1. go into the if block
  2. Exit the program
  3. Continue the code after skipping the if block
  4. None of these

Answer: C) Continue the code after skipping the if block

55. What will be the result of the following condition?

(! (25 > 25))

  1. True
  2. False
  3. Error
  4. None of these

Answer: A) True

56. Which statement is required to execute a block of code when the condition is false?

  1. for
  2. if
  3. else
  4. All of these

Answer: C) else

57. Can the else statement exist without the if statement in C?

  1. Yes
  2. No

Answer: B) No

58. Which of these if…else block syntax is correct?

A.

if(condition){
}
else {
}

B.

if(condition){
}
else(condition){
}

C.

if{}

D. None of these

Answer: A)

if(condition){
}
else {
}

59. The if-elseif-else statement in C programming is used?

  1. Create multiple conditional statements
  2. Return values
  3. Loop in if-else block
  4. All of these

Answer: A) Create multiple conditional statements

60. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    int marks = 43;
    if (marks > 90)
        printf("Grade : A ");
    else if (marks > 75)
        printf("Grade : B ");
    else if (marks > 60)
        printf("Grade : C ");
    if (marks > 40)
        printf("Grade : D ");
    else
        printf("Fail ");
    return 0;
}
  1. Grade : A
  2. Grade : B
  3. Grade : C
  4. Grade : D

Answer: D) Grade : D

61. How many expressions can be checked using if…elseif…else statement?

  1. 100
  2. 1
  3. Infinite
  4. None of these

Answer: C) Infinite

62. Is it possible to nest if-else statements in C programming?

  1. Yes
  2. No

Answer: A) Yes

63. Which of the following syntax is correct for nested if-else statements?

A.

 if(exp1){
	if(exp2){
	}
}
else {
	if(exp3){
	}
}

B.

B.	if(exp1){
}else {
}

C.

if{}

D. None of these

Answer: A)

 if(exp1){
	if(exp2){
	}
}
else {
	if(exp3){
	}
}

64. What will be the output of the following C code?

#include <stdio.h>

int main(){
    int n = 65;
    if (n >= 75) {
        if (n >= 95) {
            printf("Excellent");
        }
        else
            printf("Pass");
    }
    else
        printf("Fail");
}
  1. Excellent
  2. Pass
  3. Fail
  4. None of these

Answer: C) Fail

65. Multiple values of the same variable can be tested using ___.

  1. switch
  2. for
  3. Function
  4. All of these

Answer: A) switch

66. Without a break statement in switch what will happen?

  1. All cases will work properly
  2. Cases will fall through after matching the first check
  3. Switch will throw error
  4. All of these

Answer: B) Cases will fall through after matching the first check

67. When all cases are unmatched which case is matched in a switch statement?

  1. Default case
  2. First case
  3. No case
  4. None of these

Answer: A) Default case

68. What will be the output of the following C code?

#include <stdio.h>
int main(){
    char grade = 'B';
    switch (grade) {
    case 'A':
        printf("Excellent!\n");
    case 'B':
    case 'C':
        printf("Well done\n");
    case 'D':
        printf("You passed\n");
    case 'F':
        printf("Better try again\n");
        break;
    default:
        printf("Invalid grade\n");
    }
}
  1. Well done
  2. You passed
  3. Better try again
  4. All of these

Answer: D) All of these

69. Loops in C programming are used to ___.

  1. Execute a statement based on a condition
  2. Execute a block of code repeatedly
  3. Create a variable
  4. None of these

Answer: B) Execute a block of code repeatedly

70. Which of these is an exit-controlled loop?

  1. for
  2. if
  3. do…while
  4. while

Answer: C) do…while

71. Which statements are used to change the execution sequence?

  1. Loop control statement
  2. Function statement
  3. Conditional statement
  4. All of these

Answer: A) Loop control statement

72. What will happen if the loop condition will never become false?

  1. Program will throw an error
  2. Program will loop infinitely
  3. Loop will not run
  4. None of these

Answer: B) Program will loop infinitely

73. Which of these statements is correct in case of while loop in C?

  1. Executes the block till the condition become false
  2. Is an entry controlled loop
  3. There might be condition when the loop will not execute at all
  4. All of these

Answer: D) All of these

74. Which of the following is valid syntax for creating a while loop?

A.while{} (condition)

B.while(condition){}

C.while{}

D.All of these

Answer: B)while(condition){}

75. What will be the output of the following C code?

#include <stdio.h>
int main(){
    int a = 11;
    while (a < 20) {
        printf("%d  ", a);
        a += 2;
    }

    return 0;
}
  1. 11 13 15 17 19
  2. 11 12 13 14 15 16 17 18 19 20
  3. 11 13 15 17 19 21
  4. None of these

Answer: A) 11 13 15 17 19

76. Which loop executes the block a specific number of times?

  1. while loop
  2. for loop
  3. do…while loop
  4. All of these

Answer: B) for loop

77. Which of the following parts of the for loop can be eliminated in C?

  1. init
  2. condition
  3. increment
  4. All of these

Answer: D) All of these

78. When all parts of the for loop are eliminated, what will happen?

  1. For loop will not work
  2. Infinite for loop
  3. Error
  4. None of these

Answer: B) Infinite for loop

79. When the condition of the do-while loop is false, how many times will it execute the code?

  1. 0
  2. 1
  3. Infinite
  4. All of these

Answer: B) 1

80. Can a loop be nested in C programming?

  1. Yes
  2. No

Answer: A) Yes

81. What will be the output of the following C code?

#include <stdio.h>
int main(){
    int i, j;
    for (i = 2; i < 10; i++) {
        for (j = 2; j <= (i / j); j++)
            if (!(i % j))
                break;
        if (j > (i / j))
            printf("%d ", i);
    }
    return 0;
}
  1. 2 3 4 5 6 7 8 9
  2. 3 5 7 9
  3. 2 3 5 7
  4. 2 3 5 7 11

Answer: C) 2 3 5 7

5) C Strings MCQs

82. A string is terminated by ___.

  1. Newline (‘\n’)
  2. Null (‘\0’)
  3. Whitespace
  4. None of the above

Answer: B) Null (‘\0’)

83. Consider the below statement, can we assign a string to variable like this:

char c[100];

c = “C programming”;

  1. Yes
  2. No

Answer: B) No

84. Which format specifier is used to read and print the string using printf() and scanf() in C?

  1. %c
  2. %str
  3. %p
  4. %s

Answer: D) %s

85. Which function is used to read a line of text including spaces from the user in C?

  1. scanf()
  2. getc()
  3. fgets()
  4. All of the above

Answer: C) fgets()

86. Which function is used to concatenate two strings in C?

  1. concat()
  2. cat()
  3. stringcat()
  4. strcat()

Answer: D) strcat()

87. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    char str1[] = { 'H', 'e', 'l', 'l', 'o' };
    char str2[] = "Hello";
    printf("%ld,%ld", sizeof(str1), sizeof(str2));
    return 0;
}
  1. 5,5
  2. 6,6
  3. 5,6
  4. None of the above

Answer: C) 5,6

88. What will be the output of the following C code?

#include <stdio.h>
int main()
{
    char str1[] = "Hello";
    char str2[10];
    str2 = str1;
    printf("%s,%s", str1, str2);
    return 0;
}
  1. Hello,
  2. Hello,Hello
  3. Hello,HelloHello
  4. Error

Answer: D) Error

89. What will be the output of the following C code? (If the input is “Hello world”)

#include <stdio.h>
int main()
{
    char str[30];
    scanf("%s", str);
    printf("%s", str);
    return 0;
}
  1. Hello world
  2. Hello
  3. Hello world\0
  4. Error

Answer: B) Hello

90. Which function is used to compare two strings in C?

  1. strcmp()
  2. strcmpi()
  3. compare()
  4. cmpi()

Answer: A) strcmp()

91. Which function is used to compare two strings with ignoring case in C?

  1. strcmp()
  2. strcmpi()
  3. compare()
  4. cmpi()

Answer: B) strcmpi()

92. Which is the correct syntax to declare an array in C?

  1. data_type array_name[array_size];
  2. data_type array_name{array_size};
  3. data_type array_name[];
  4. All of the above

Answer: A) data_type array_name[array_size];

93. You can access elements of an array by ___.

  1. values
  2. indices
  3. memory addresses
  4. All of the above

Answer: B) indices

94. Which is/are the correct syntax to initialize an array in C?

  1. data_type array_name[array_size] = {value1, value2, value3, …};
  2. data_type array_name[] = {value1, value2, value3, …};
  3. data_type array_name[array_size] = {};
  4. Both A and B

Answer: D) Both A and B

95. Array elements are always stored in ___ memory locations.

  1. Random
  2. Sequential
  3. Both A and B
  4. None of the above

Answer: B) Sequential

96. Let x is an integer array with three elements having value 10, 20, and 30. What will be the output of the following statement?

printf(“%u”,x);

  1. Prints the value of 0th element (i.e., 10)
  2. Prints the garbage value
  3. An error occurs
  4. Print the address of the array (i.e., the address of first (0th) element

Answer: D) Print the address of the array (i.e., the address of first (0th) element

97. What will be the output of the following C program?

#include <stdio.h>
int main()
{
    int x[5] = { 10, 20, 30 };
    printf("%d", x[3]);
    return 0;
}
  1. 0
  2. 30
  3. Garbage value
  4. Error

Answer: A) 0

98. What will be the output of the following C program?

#include <stdio.h>
int main()
{
    int x[5] = { 10, 20, 30 };
    printf("%d", x[-1]);
    return 0;
}
  1. 0
  2. 10
  3. Garbage value
  4. Error

Answer: C) Garbage value

99. What will be the output of the following C program?

#include <stdio.h>
int main()
{
    int x[5] = { 10, 20, 30 };
    printf("%ld", sizeof(x)/sizeof(x[0]));
    return 0;
}
  1. 3
  2. 4
  3. 5
  4. 6

Answer: C) 5

100. What will be the output of the following C program?

#include <stdio.h>
int main()
{
    int x[5] = { 10, 20, 30 };
    printf("%d", x[3]);
    return 0;
}
  1. 0
  2. 30
  3. Garbage value
  4. Error

Answer: A) 0

101. What will be the output of the following C program?

#include <stdio.h>
int main()
{
    int x[5] = { 10, 20, 30 };
    printf("%d", x[-1]);
    return 0;
}
  1. 0
  2. 10
  3. Garbage value
  4. Error

Answer: C) Garbage value

102. If we pass an array as an argument to a function, what actually gets passed?

  1. Value of elements in array
  2. First element of the array
  3. Base address of the array i.e., the address of the first element
  4. Address of the last element of array

Answer: C) Base address of the array i.e., the address of the first element

7) C Structures and Union MCQs

103. Which of the following is the collection of different data types?

  1. structure
  2. string
  3. array
  4. All of the above

Answer: A) structure

104. Which operator is used to access the member of a structure?

  1. >
  2. *
  3. .

Answer: D) .

105. Which of these is a user-defined data type in C?

  1. int
  2. union
  3. char
  4. All of these

Answer: B) union

106. “A union can contain data of different data types”. True or False?

  1. True
  2. False

Answer: A) True

107. Which keyword is used to define a union?

  1. un
  2. union
  3. Union
  4. None of these

Answer: B) union

108. The size of a union is ___.

  1. Sum of sizes of all members
  2. Predefined by the compiler
  3. Equal to size of largest data type
  4. None of these

Answer: C) Equal to size of largest data type

109. All members of union ___.

  1. Stored in consecutive memory location
  2. Share same memory location
  3. Store at different location
  4. All of these

Answer: B) Share same memory location

110. Which of the below statements is incorrect in case of union?

  1. Union is a user-defined data structure
  2. All data share same memory
  3. Union stores methods too
  4. union keyword is used to initialize

Answer: C) Union stores methods too

111. The members of union can be accessed using ___.

  1. Dot Operator (.)
  2. And Operator (&)
  3. Asterisk Operator (*)
  4. Right Shift Operator (>)

Answer: A) Dot Operator (.)

112. In which case union is better than structure?

  1. Less memory is available
  2. Faster compilation is required
  3. When functions are included
  4. None of these

Answer: A) Less memory is available

113. Which is the correct syntax to create a union?

  1. union union_name { };
  2. union union_name { }
  3. union union_name ( );
  4. union union_name ( )

Answer: A) union union_name { };

114. What will be the output of the following C program?

#include <stdio.h>
union values {
    int val1;
    char val2;
} myVal;
int main()
{
    myVal.val1 = 66;
    printf("val1 = %p", &myVal.val1);
    printf("\nval2 = %p", &myVal.val2);
    return 0;
}

A. val1 = 0x54ac88dd2012 val2 = 0x55ac76dd2014

B. Error

C. val1 = 0x55ac76dd2014 val2 = 0x55ac76dd2014

D.Exception

Answer: C) val1 = 0x55ac76dd2014 val2 = 0x55ac76dd2014

8) C Functions MCQs

115. What is a function in C?

  1. User defined data type
  2. Block of code which can be reused
  3. Declaration syntax
  4. None of these

Answer: B) Block of code which can be reused

116. Functions in C can accept multiple parameters. True or False?

  1. True
  2. False

Answer: A) True

117. Which keyword is used to return values from function?

  1. Return
  2. Value
  3. Return type
  4. All of these

Answer: C) Return type

118. Which of these is not a valid parameter passing method in C?

  1. Call by value
  2. Call by reference
  3. Call by pointer
  4. All of these

Answer: C) Call by pointer

119. A C program contains ___.

  1. At least one function
  2. No function
  3. No value from command line
  4. All of these

Answer: A) At least one function

120. A recursive function in C ___.

  1. Call itself again and again
  2. Loop over a parameter
  3. Return multiple values
  4. None of these

Answer: A) Call itself again and again

121. The scope of a function is limited to?

  1. Current block
  2. Only function
  3. Whole file
  4. Directory

Answer: C) Whole file

122. Which of the below syntax is the correct way of declaring a function?

A. return function_name () { }

B. data_type function_name (parameter) { }

C. Void function_name ( )

D. None of these

Answer: B)

data_type function_name (parameter){ }

123. The sqrt() function is used to calculate which value?

  1. Square
  2. Square of reverse bits
  3. Square root
  4. None of these

Answer: C) Square root

124. What will be the output of the following C program?

#include <stdio.h>
int myFunc(int x){
    return (--x);
}
int main(){
    int a = myFunc(13);
    printf("%d", a);
    return 0;
}
  1. 13
  2. 12
  3. 14
  4. Error

Answer: B) 12

9) C Pointers MCQs

125. Before using a pointer variable, it should be ___.

  1. Declared
  2. Initialized
  3. Both A. and B.
  4. None of the above

Answer: C) Both A. and B.

126. An uninitialized pointer in C is called ___.

  1. Void pointer
  2. Empty pointer
  3. Invalid pointer
  4. Wild pointer

Answer: D) Wild pointer

127. ___ is a pointer that occurs at the time when the object is de-allocated from memory without modifying the value of the pointer.

  1. Dangling pointer
  2. Wild pointer
  3. Void pointer
  4. Null pointer

Answer: A) Dangling pointer

128. A ___ can be assigned the address of any data type.

  1. Dangling pointer
  2. Wild pointer
  3. Void pointer
  4. Null pointer

Answer: C) Void pointer

129. Which pointer is called general-purpose pointer?

  1. Dangling pointer
  2. Wild pointer
  3. Void pointer
  4. Null pointer

Answer: C) Void pointer

130. Pointer arithmetic is not possible on ___.

  1. Integer pointers
  2. Float pointers
  3. Character pointers
  4. Void pointers

Answer: D) Void pointers

131. Comment on the following pointer declaration?

int *p, x;

  1. p is a pointer to integer, x is not
  2. p and x, both are pointers to integer
  3. p is pointer to integer, x may or may not be
  4. p and x both are not pointers to integer

Answer: A) p is a pointer to integer, x is not

132. What will be the output of the following C code?

#include <stdio.h>
int main(){
    int x = 10, *ptr;
    ptr = &x;
    *ptr = 20;
    printf("%d", x);
}
  1. 10
  2. 20
  3. Error
  4. A garbage value

Answer: B) 20

133. What will be the output of the following C code?

#include <stdio.h>
int main(){
    char* ptr;
    ptr = "progies";
    printf("%c", *&*ptr);
    return 0;
}
  1. progies
  2. I
  3. Some address
  4. Error

Answer: B) I

134. What is the correct syntax to declare pointer to pointer i.e., double pointer?

  1. type **pointer_name;
  2. type *&pointer_name;
  3. type *(*pointer_name);
  4. type **(pointer_name);

Answer: A) type **pointer_name;

135. What is ptr in the given statement?

int (*ptr)[5];

  1. ptr is an array of 5 pointers
  2. ptr is a simple integer array
  3. ptr is a pointer to a 5 elements integer array
  4. None of the above

Answer: C) ptr is a pointer to a 5 elements integer array

136. What is the correct syntax to declare a pointer to a constant?

  1. const type *pointer_name;
  2. type const *pointer_name;
  3. Both A. and B.
  4. None of the above

Answer: A) const type *pointer_name;

10) C File Handling MCQs

137. Which function is used to open a file in C?

  1. open()
  2. fopen()
  3. file_open()
  4. fileopen()

Answer: B) fopen()

138. Which character(s) is/are used to open a binary file in append mode in C?

  1. a
  2. b
  3. ba
  4. ab

Answer: D) ab

139. Which character(s) is/are used to open a binary file in reading and writing mode in C?

  1. rw
  2. rwb
  3. rb+
  4. rwb

Answer: C) rb+

140. Which is the correct syntax to declare a file pointer in C?

  1. File *file_pointer;
  2. FILE *file_pointer;
  3. File file_pointer;
  4. FILE *file_pointer;

Answer: B) FILE *file_pointer;

141. Which function is used to close an opened file in C?

  1. close()
  2. fclose()
  3. file_close()
  4. fileclose()

Answer: B) fclose()

142. Function fwrite() works with ___.

  1. Text files
  2. Binary files
  3. Both A. and B.
  4. None of the above

Answer: B) Binary files

143. What is the value of EOF in C?

  1. -1
  2. 0
  3. 1
  4. Null

Answer: A) -1

144. Which function checks the end-of-file indicator for the given stream in C?

  1. eof()
  2. EOF
  3. feof()
  4. None of the above

Answer: C) feof()

145. Which function is used to seek the file pointer position in C?

  1. seek()
  2. fseek()
  3. fileseek()
  4. fmove()

Answer: B) fseek()

146. Which function is used to delete an existing file in C?

  1. delete()
  2. fremove()
  3. frem()
  4. remove()

Answer: D) remove()

11) C Preprocessor MCQs

147. What is CPP in C programming?

  1. C processing platform
  2. C PreProcessor
  3. C pre-platform
  4. None of these

Answer: B) C PreProcessor

148. Which symbol is used to begin a preprocessor?

  1. @
  2. !
  3. #
  4. All of these

Answer: C) #

149. Which of these is a valid preprocessor in C?

  1. #include
  2. #if
  3. #error
  4. All of these

Answer: D) All of these

150. (\) operator in C is ___.

  1. Macro continuation operator
  2. Stringize operator
  3. Tokenizer
  4. None of these

Answer: A) Macro continuation operator

151. Which operator is used to stringize variables in C?

  1. /
  2. &
  3. *
  4. #

Answer: D) #

152. Is it possible in a C program to merge two tokens into one token?

  1. Yes
  2. No

Answer: A) Yes

153. Which of these is not a valid preprocessor in C?

  1. \
  2. ?
  3. ###
  4. None of these

Answer: B) ?

154. Header files ___.

  1. Contain function declarations
  2. Can be included to a program
  3. End with .h extension
  4. All of these

Answer: D) All of these

155. Can programmers create their own header files?

  1. Yes
  2. No

Answer: A) Yes

156. Which of these is valid syntax to include a header in C?

  1. #include <header>
  2. #include “header”
  3. Both A and B
  4. All of these

Answer: C) Both A and B

157. What will happen if a header file is included in a program twice?

  1. Program will throw an error
  2. Program will throw an exception
  3. Program will run normally
  4. None of these

Answer: A) Program will throw an error

158. Which syntax is correct to include a specific preprocessor based on configuration?

  1. #defif system1 <system.h>
  2. #include system1 “system.h”
  3. import <system.h> if system1
  4. All of these

Answer: B) #include system1 “system.h”

The content uploaded on this website is for reference purposes only. Please do it yourself first.