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 2

1. Which operator is used to declare a pointer variable in C?
A) &
B) *
C) ->
D) %

B) *

2. What is the correct syntax to declare a function in C?
A) function fun()
B) void fun()
C) def fun()
D) declare fun()

B) void fun()

3. Which header file is required for malloc() and free()?
A) stdio.h
B) stdlib.h
C) memory.h
D) alloc.h

B) stdlib.h

4. Which keyword prevents modification of a variable?
A) static
B) final
C) const
D) volatile

C) const

5. What is the output of: printf("%d", 5/2);
A) 2
B) 2.5
C) 3
D) Compilation error

A) 2

6. Which is the correct way to access an array element?
A) a(i)
B) a[i]
C) a{i}
D) a<i>

B) a[i]

7. Which operator is used to access structure members using a pointer?
A) .
B) :
C) ->
D) *

C) ->

8. Which type of memory allocation occurs at compile time?
A) Dynamic
B) Static
C) Heap
D) Virtual

B) Static

9. What is the output of sizeof(10.5)?
A) 2
B) 4
C) 8
D) Depends on compiler

C) 8

10. Which function is used to deallocate memory?
A) delete()
B) free()
C) remove()
D) clear()

B) free()

11. Which storage class gives fastest access?
A) auto
B) static
C) register
D) extern

C) register

12. What does the continue statement do?
A) Terminates loop
B) Skips current iteration
C) Exits program
D) Restarts loop

B) Skips current iteration

13. Which data type is used to store a single character?
A) int
B) char
C) float
D) double

B) char

14. What is recursion?
A) Looping
B) Function calling itself
C) Calling another function
D) Iteration only

B) Function calling itself

15. Which of the following is NOT a keyword in C?
A) goto
B) sizeof
C) typedef
D) include

D) include

16. Which function reads formatted input?
A) gets()
B) scanf()
C) puts()
D) printf()

B) scanf()

17. What is the index of the first element in a C array?
A) 0
B) 1
C) -1
D) Depends on compiler

A) 0

18. Which operator is used for bitwise OR?
A) |
B) ||
C) &
D) ^

A) |

19. Which variable is visible only within a function?
A) Global
B) Local
C) Static
D) Extern

B) Local

20. Which keyword is used to create a type alias?
A) struct
B) typedef
C) enum
D) union

B) typedef

21. Which function compares strings ignoring case?
A) strcmp()
B) strcasecmp()
C) strncmp()
D) strcpy()

B) strcasecmp()

22. Which symbol represents a NULL pointer?
A) 0
B) '0'
C) NULL
D) -1

C) NULL

23. Which function copies one string to another?
A) strcat()
B) strcmp()
C) strcpy()
D) strlen()

C) strcpy()

24. Which operator is used to get the address of a variable?
A) *
B) &
C) %
D) #

B) &

25. What is the size of char data type?
A) 1 byte
B) 2 bytes
C) 4 bytes
D) Depends on compiler

A) 1 byte