Learn C MCQs

Prepare C MCQs (Multiple choice Questions) for exam and job interviews.

Which of the following is the correct way to take input in C?

1) input()

2) get()

3) scanf()

4) cin>>

Answer : Option 3

Which of the following is a valid keyword in C?

1) input

2) None of the above

3) int

4) define

Answer : Option 3

Which function is used to dynamically allocate memory in C?

1) calloc()

2) new()

3) malloc()

4) alloc()

Answer : Option 3

Which of the following is a relational operator in C?

1) =

2) *

3) <

4) +

Answer : Option 3

How do you return a value from a function in C?

1) give value;

2) return value;

3) send value;

4) exit value;

Answer : Option 2

What is the maximum value that can be stored in an unsigned int?

1) 65535

2) 32767

3) 2147483647

4) Depends on the system

Answer : Option 4

Which keyword is used to include external files in C?

1) import

2) #define

3) #include

4) use

Answer : Option 3

What does the following line of code do: int *ptr = &a;

1) Creates a pointer to a

2) Assigns the address of a to ptr

3) Both a and b

4) None of the above

Answer : Option 2

How do you declare a structure in C?

1) struct myStruct { int a; };

2) struct myStruct = { int a; };

3) structure myStruct { int a; };

4) None of the above

Answer : Option 1

What is the correct way to use a function from a library in C?

1) Include the library and call the function

2) Just call the function

3) Declare the function

4) None of the above

Answer : Option 1