



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Multiple Choice — 35 Questions
Total Marks: 35 | Time Allowed: 60 minutes | Each question carries 1 mark
Name: ___________________________________ Student ID: _____________________
Date: ____________________________________ Score: ________ / 35
Instructions: Circle or write the letter of the best answer for each question. Each question is worth 1 mark. No marks are deducted for wrong answers.
Q1. What is the correct syntax to print "Hello, World!" in C? A. printf("Hello, World!"); B. print("Hello, World!"); C. echo "Hello, World!"; D. cout << "Hello, World!";
Q2. Which of the following is a valid variable declaration in C? A. int 2var; B. int var2; C. int var-2; D. int var 2;
Q3. What does the following code output? int x = 5; printf("%d", x++); A. 6 B. 5 C. 4 D. Compile error
Q4. Which header file is required for using printf() in C? A. string.h B. math.h C. stdio.h D. stdlib.h
Q5. What is the size of an int data type in C on most 32-bit systems? A. 1 byte B. 2 bytes C. 4 bytes
D. 8 bytes
Q6. Which operator is used to access the value at a pointer address?
A. & B. * C. -> D..
Q7. What will be the output of the following code?
int a = 10, b = 3; printf("%d", a % b); A. 3 B. 1 C. 0 D. 2
Q8. Which loop in C always executes its body at least once?
A. for loop B. while loop C. do-while loop D. foreach loop
Q9. What is the correct way to declare a pointer to an integer in C?
A. int ptr; B. int &ptr; C. int *ptr; D. pointer int ptr;
Q10. What does the malloc() function return if it fails to allocate memory?
A. 0 B. - C. NULL D. undefined
Q11. Which of the following is NOT a valid storage class in C?
A. auto B. extern C. static D. dynamic
Q12. What is the output of the following code?
char c = 'A'; printf("%d", c); A. A B. 65
B. x cannot be modified after initialization C. x is a pointer D. x is a global variable
Q20. What is the correct way to call a function named 'sum' with arguments 3 and 5?
A. call sum(3,5); B. sum(3, 5); C. sum{3, 5}; D. function sum(3, 5);
Q21. Which of the following correctly defines a function that returns an integer?
A. void int myFunc() {} B. int myFunc() {} C. myFunc() int {} D. return int myFunc() {}
Q22. What is the result of the expression: 5 > 3 && 2 < 4?
A. 0 B. 1 C. - D. true (non-numeric)
Q23. In C, what is a 'null terminator' in a string?
A. '\n' B. '\0' C. '\t' D. '\r'
Q24. What will the following code print?
for(int i=0; i<3; i++){ printf("%d ", i); } A. 1 2 3 B. 0 1 2 C. 0 1 2 3 D. Compile error
Q25. Which of the following is used to dynamically free allocated memory?
A. delete() B. dealloc() C. free() D. remove()
Q26. What is recursion in C?
A. A loop that runs infinitely
B. A function that calls itself C. A pointer to a function D. A type of array
Q27. Which bitwise operator is used to perform AND operation?
A. || B. && C. & D. |
Q28. What will the following code print?
int a = 5; if(a > 3) printf("Yes"); else printf("No"); A. No B. Yes C. Yes No D. Compile error
Q29. Which of the following is the correct way to declare a 2D array of integers (3 rows, 4 columns)?
A. int arr[4][3]; B. int arr[3][4]; C. int arr(3,4); D. int[3][4] arr;
Q30. What does 'void' mean as a function return type?
A. Returns zero B. Returns nothing C. Returns a pointer D. Returns a boolean
Q31. What is the output of this code?
printf("%d", sizeof(char)); A. 2 B. 4 C. 1 D. 8
Q32. Which of the following is the correct way to open a file for reading in C?
A. fopen("file.txt", "w") B. fopen("file.txt", "r") C. open("file.txt", "read")