Docsity

C Programming Multiple Choice Exam (35 Questions), Exams of Computer Science

Toggle sidebar
bg1
C Programming Multiple Choice Exam (35
Questions)
Instructions: Choose the correct answer for each question.
1. Which of the following is the correct extension for a C source file?
A. .java
B. .cpp
C. .c
D. .py
Answer: C
2. Which function is the entry point of a C program?
A. start()
B. main()
C. begin()
D. execute()
Answer: B
3. Which header file is required for using printf()?
A. string.h
B. conio.h
C. stdio.h
D. math.h
Answer: C
4. Which symbol is used to end a statement in C?
A. :
B. .
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download C Programming Multiple Choice Exam (35 Questions) and more Exams Computer Science in PDF only on Docsity!

C Programming Multiple Choice Exam (

Questions)

Instructions: Choose the correct answer for each question.

1. Which of the following is the correct extension for a C source file?

A. .java B. .cpp C. .c D. .py Answer: C

2. Which function is the entry point of a C program?

A. start() B. main() C. begin() D. execute() Answer: B

3. Which header file is required for using printf()?

A. string.h B. conio.h C. stdio.h D. math.h Answer: C

4. Which symbol is used to end a statement in C?

A. :

B..

C. ;

D. ,

Answer: C

5. Which data type is used to store integer values?

A. float B. int C. char D. double Answer: B

6. What is the size of char in C?

A. 1 byte B. 2 bytes C. 4 bytes D. 8 bytes Answer: A

7. Which operator is used for assignment?

A. ==

B. =

C. !=

D. <=

Answer: B

8. Which operator is used to compare two values?

A. =

B. &&

C. ==

D. ++

13. Which symbol is used for single-line comments in C?

A.

B. //

C.

D. **

Answer: B

14. Which of the following is a logical operator?

A. +

B. &&

C. %

D. /

Answer: B

15. What is the output of 10 % 3?

A. 3

B. 1

C. 0

D. 10

Answer: B

16. Which loop is best when the number of iterations is known?

A. while B. do-while C. for D. infinite loop Answer: C

17. Which keyword is used to exit a loop?

A. stop B. continue C. break D. return Answer: C

18. Which function is used to find the length of a string?

A. strlen() B. size() C. strlength() D. count() Answer: A

19. Arrays in C start indexing from:

A. 1

B. 0

C. - 1

D. Depends on compiler Answer: B

20. Which data type stores decimal numbers?

A. int B. char C. float D. short Answer: C

21. Which keyword is used to create a structure?

C. strcmp() D. strlen() Answer: A

26. Which header file is used for mathematical functions?

A. math.h B. string.h C. stdlib.h D. ctype.h Answer: A

27. Which keyword is used to return a value from a function?

A. break B. stop C. return D. end Answer: C

28. Which operator increases a value by 1?

A. --

B. ++

C. +=

D. ==

Answer: B

29. What is the output of printf("%d", 2*3+4);?

A. 10

B. 14

C. 12

D. 24

Answer: A

30. Which statement is used for decision making?

A. switch B. if C. if-else D. All of the above Answer: D

31. Which function dynamically allocates memory?

A. free() B. malloc() C. sizeof() D. callocfree() Answer: B

32. Which keyword is used to define a macro?

A. #define B. macro C. define D. typedef Answer: A

33. Which function releases dynamically allocated memory?

A. delete() B. remove() C. free() D. clear() Answer: C