A Learning Platform

SUCCESS

Success = Discipline + Consistency + Sacrifice.
Discipline - in what you do.
Consistency - in what you do.
Sacrifice - for what you do.

                   -- Manjunatha C. P. --

C PROGRAMMING MCQ SET 4

1. Which of the following best describes a preprocessor directive?
A) It executes at runtime
B) It is handled before compilation
C) It is part of linker
D) It executes after compilation

B) It is handled before compilation

2. Which operator is used to concatenate strings in C?
A) +
B) &
C) strcat()
D) *

C) strcat()

3. What does the sizeof operator return?
A) Address of variable
B) Size in bits
C) Size in bytes
D) Value of variable

C) Size in bytes

4. Which of the following is NOT a valid escape sequence?
A) \n
B) \t
C) \a
D) \z

D) \z

5. Which keyword is used to declare a union?
A) struct
B) typedef
C) union
D) enum

C) union

6. Which operator is used to test multiple conditions in a single expression?
A) &
B) &&
C) |
D) !

B) &&

7. Which function is used to read a character from standard input?
A) getc()
B) getchar()
C) read()
D) scanf()

B) getchar()

8. Which of the following is a valid pointer declaration?
A) int *p;
B) int p*;
C) *int p;
D) pointer int p;

A) int *p;

9. What is the purpose of the continue statement?
A) Exit loop
B) Skip current iteration
C) Restart program
D) Pause execution

B) Skip current iteration

10. Which function is used to close a file?
A) fclose()
B) close()
C) end()
D) stop()

A) fclose()

11. Which header file contains exit() function?
A) stdio.h
B) stdlib.h
C) conio.h
D) process.h

B) stdlib.h

12. What is the range of unsigned char?
A) -128 to 127
B) 0 to 255
C) 0 to 127
D) -255 to 255

B) 0 to 255

13. Which type of array stores elements in contiguous memory locations?
A) One-dimensional array
B) Two-dimensional array
C) Jagged array
D) Pointer array

A) One-dimensional array

14. Which function is used to write a string to standard output?
A) printf()
B) puts()
C) write()
D) fprintf()

B) puts()

15. Which keyword is used to make a variable global across files?
A) static
B) extern
C) global
D) register

B) extern

16. Which function converts an integer to a string?
A) atoi()
B) itoa()
C) strtoi()
D) intstr()

B) itoa()

17. What is the default storage class of local variables?
A) auto
B) static
C) register
D) extern

A) auto

18. Which operator is used to dereference a pointer?
A) &
B) *
C) ->
D) %

B) *

19. Which loop is best suited when the number of iterations is known?
A) while
B) do-while
C) for
D) infinite loop

C) for

20. Which function determines the length of a string?
A) sizeof()
B) strlen()
C) strsize()
D) length()

B) strlen()

21. Which operator has the highest precedence?
A) =
B) &&
C) *
D) ||

C) *

22. Which function reads a character from a file?
A) fscanf()
B) getc()
C) fgets()
D) fputs()

B) getc()

23. What is the output of expression: 5 % 2 ?
A) 2
B) 2.5
C) 1
D) 0

C) 1

24. Which function is used to compare strings up to n characters?
A) strcmp()
B) strncmp()
C) strstr()
D) strcpy()

B) strncmp()

25. Which header file contains string handling functions?
A) math.h
B) string.h
C) ctype.h
D) memory.h

B) string.h