Skip to main content

Learning Resources

Top 50 Interview MCQ

Top 50 C multiple-choice questions covering all concepts of the language. Choose an option and press Show Answer to see instantly whether you were right, along with the reason.

Top 50 MCQs

C Interview MCQ Practice

Fifty multiple-choice questions covering every concept of C — basics, data types, operators, control flow, arrays, strings, functions, recursion, storage classes, pointers, dynamic memory, structures, file handling, the preprocessor, enum and typedef. Pick an option, then press Show Answer to find out whether you were right and why.

BasicsData TypesOperatorsControl FlowArraysStringsFunctionsStorage ClassesPointersDynamic MemoryStructuresFile HandlingPreprocessorEnum & TypedefMiscellaneous
0 Attempted
0 Correct
0 Wrong
50 Total
Q1 Basics

Which of the following is the correct entry point of every C program?

Q2 Basics

Who developed the C programming language?

Q3 Basics

How many keywords are there in standard C89?

Q4 Data Types

What is the output of printf("%d", sizeof(char)); on any conforming compiler?

Q5 Data Types

Which format specifier is used to print a double with scanf?

Q6 Data Types

What does the volatile keyword tell the compiler?

Q7 Data Types

What is the value of 5 / 2 in C?

Q8 Operators

If int i = 5; what is the value of j after j = i++;?

Q9 Operators

What does the expression 8 >> 2 evaluate to?

Q10 Operators

Which is the only ternary operator in C?

Q11 Operators

In the expression (a && b), when is b NOT evaluated?

Q12 Control Flow

Which loop is guaranteed to execute its body at least once?

Q13 Control Flow

What happens if break is omitted in a switch case?

Q14 Control Flow

Which data type is NOT allowed in a switch expression?

Q15 Control Flow

What does the continue statement do inside a loop?

Q16 Arrays

What happens when you access an array beyond its bounds?

Q17 Arrays

How is a 2D array stored in memory in C?

Q18 Arrays

What is the expression a[i] equivalent to?

Q19 Arrays

Inside a function with parameter int a[], what does sizeof(a) give?

Q20 Strings

For char s[10] = "hello"; what are strlen(s) and sizeof(s)?

Q21 Strings

Which function is the safe replacement for gets()?

Q22 Strings

How do you correctly compare two strings s1 and s2?

Q23 Strings

What is wrong with char *s = "hi"; s[0] = 'H';?

Q24 Functions

C passes arguments to functions by which mechanism?

Q25 Functions

What is the purpose of a function prototype?

Q26 Functions

What must every recursive function have to terminate?

Q27 Storage Classes

What does a static local variable retain between function calls?

Q28 Storage Classes

Which storage class makes a global variable private to its own source file?

Q29 Storage Classes

Which operation is illegal on a register variable?

Q30 Pointers

What does a pointer variable store?

Q31 Pointers

What is a dangling pointer?

Q32 Pointers

If int *p points to an int and p holds address 1000, what is p + 1 on a 4-byte-int machine?

Q33 Pointers

Which pointer type can hold the address of any data type?

Q34 Pointers

In const char *p, what is constant?

Q35 Dynamic Memory

Which function allocates memory and initialises it to zero?

Q36 Dynamic Memory

What does malloc return when it fails?

Q37 Dynamic Memory

Where is dynamically allocated memory stored?

Q38 Structures

What is sizeof a union with an int, a float, and a char (4-byte int and float)?

Q39 Structures

Which operator accesses a structure member through a pointer?

Q40 Structures

Can two structure variables be compared using ==?

Q41 File Handling

Which fopen mode erases the contents of an existing file?

Q42 File Handling

Why must the return of fgetc be stored in an int rather than a char?

Q43 File Handling

In main(int argc, char *argv[]), what does argv[0] contain?

Q44 Preprocessor

What does #define SQ(x) x*x give for SQ(2+3)?

Q45 Preprocessor

What is the purpose of an include guard?

Q46 Preprocessor

What does the ## operator do in a macro?

Q47 Preprocessor

Which predefined macro gives the current line number?

Q48 Enum & Typedef

In enum Color { RED, GREEN, BLUE };, what is the value of BLUE?

Q49 Enum & Typedef

With #define P char * and the line P a, b; what is b?

Q50 Miscellaneous

Which of these is the most common cause of a segmentation fault?