




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A practice exam for the clacla c programming language certified associate certification. It includes multiple-choice questions covering fundamental concepts of the c programming language, such as data types, operators, control structures, and memory management. Each question is followed by a detailed explanation of the correct answer, making it a valuable resource for students and professionals preparing for the certification exam. The practice exam helps reinforce understanding of key concepts and identify areas for further study. It is designed to assess knowledge and skills in c programming, providing a comprehensive review of essential topics.
Typology: Exams
1 / 129
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which of the following is NOT a characteristic of a high‑level programming language? A) Platform independence B) Direct manipulation of CPU registers C) Use of English‑like syntax D) Automatic memory management Answer: B Explanation: High‑level languages abstract away hardware details such as CPU registers; direct register manipulation is a feature of low‑level or assembly languages. Question 2. In the compilation process, which stage translates source code into assembly language? A) Preprocessing B) Lexical analysis C) Code generation D) Linking Answer: C Explanation: After preprocessing and parsing, the compiler’s code‑generation phase emits assembly (or machine) code from the intermediate representation.
Question 3. Which of the following is the correct minimal structure of a C program? A) int main(){} B) void start(){} C) program(){} D) main(){} Answer: A Explanation: The C standard requires a function named main returning int; an empty body is syntactically valid. Question 4. Which token is a keyword in C? A) myVar B) 42 C) while D) #include Answer: C Explanation: while is reserved by the language; identifiers, literals, and preprocessing directives are not keywords.
Question 7. What is the difference between a declaration and a definition of a variable? A) Declaration allocates storage; definition does not. B) Declaration introduces the name; definition also allocates storage. C) Declaration must include an initializer; definition must not. D) There is no difference. Answer: B Explanation: A declaration tells the compiler about the variable’s type and name; a definition also reserves memory for it. Question 8. Which statement correctly declares and initializes an int variable? A) int count; B) int count = 10; C) extern int count; D) static int; Answer: B Explanation: int count = 10; both declares the variable and provides an initializer.
Question 9. Which storage class gives a variable internal linkage and static duration? A) auto B) extern C) static D) register Answer: C Explanation: static at file scope gives internal linkage and static storage duration. Question 10. Which storage class is most appropriate for a variable that must be accessed by multiple source files? A) auto B) static C) extern D) register Answer: C Explanation: extern declares a variable defined elsewhere, allowing external linkage across translation units.
Question 13. How do you declare a pointer to a structure Point named pPtr? A) struct Point *pPtr; B) struct *Point pPtr; C) Point *pPtr; D) *struct Point pPtr; Answer: A Explanation: struct Point *pPtr; declares a pointer to a struct Point. Option C would be valid only after a typedef. Question 14. Which statement correctly creates an array of 5 struct Point objects named points? A) struct Point points[5]; B) struct Point points = 5; C) struct Point[5] points; D) points[5] struct Point; Answer: A Explanation: The syntax struct Point points[5]; declares an array of five struct Point elements.
Question 15. Which of the following is a recursive data structure? A) int arr[10]; B) struct Node { int data; struct Node *next; }; C) float matrix[3][3]; D) char *string; Answer: B Explanation: struct Node contains a pointer to the same type, enabling recursive linking (e.g., linked list). Question 16. Which integer literal is interpreted as octal? A) 0x1F B) 075 C) 0b1010 D) 123 Answer: B Explanation: An integer literal beginning with 0 (but not 0x) is octal. 075 = decimal 61. Question 17. What is the value of the expression 0xFF + 1?
"A"C) '\x41' D) Both A and C Answer: D Explanation: 'A' and '\x41' both represent the character with ASCII code 65. Question 20. In an expression, what is the result of adding an int and a char? A) The char is promoted to int and the result is int. B) The int is truncated to char. C) The result is of type char. D) Compilation error. Answer: A Explanation: Integer promotions convert char to int; the arithmetic result is of type int. Question 21. What is the result of 7 % 3? A) 1 B) 2
03Answer: A Explanation: The modulo operator yields the remainder; 7 divided by 3 leaves remainder 1. Question 22. Which relational operator tests for greater than or equal? A) > B) < C) >= D) == Answer: C Explanation: >= returns true when the left operand is greater than or equal to the right operand. Question 23. Which logical expression is equivalent to !(a && b)? A) !a && !b B) !a || !b C) a || b
Answer: A Explanation: << shifts bits toward more significant positions; shifting by 2 multiplies by 4 for unsigned integers. Question 26. What is the effect of the compound assignment a += 5? A) a = a + 5 B) a = 5 + a C) a = a - 5 D) a = a * 5 Answer: A Explanation: += adds the right‑hand operand to the left‑hand variable and stores the result. Question 27. After the statement int i = 5; i++;, what is the value of i? A) 4 B) 5 C) 6 D) Undefined
Answer: C Explanation: Post‑increment adds 1 after yielding the original value; the variable ends up as 6. Question 28. In the expression ++i + i++, assuming i starts at 3, what is the final value of i after the full expression is evaluated? A) 4 B) 5 C) 6 D) Undefined behavior Answer: D Explanation: Modifying i more than once between sequence points without an intervening sequence point causes undefined behavior. Question 29. Which operator has higher precedence? A) * (multiplication) B) + (addition) C) && (logical AND) D) = (assignment)
Answer: A Explanation: C uses the (type) syntax for explicit casts. Question 32. What does the unary & operator produce? A) The value stored at an address B) The address of its operand C) Bitwise AND of two operands D) Logical NOT Answer: B Explanation: & yields a pointer to its operand (the operand’s address). Question 33. Which declaration defines a pointer to int named p and initializes it to point to x? A) int *p = &x; B) int p = &x; C) int &p = x; D) int *p = x; Answer: A
Explanation: int *p = &x; creates a pointer p that holds the address of x. Question 34. What is the value of a NULL pointer? A) 0 B) -1 C) An address that points to the first byte of memory D) Undefined Answer: A Explanation: In C, the macro NULL expands to an implementation‑defined null pointer constant, commonly integer constant 0. Question 35. Which statement correctly declares a generic pointer? A) void *gp; B) generic *gp; C) void gp; D) any *gp; Answer: A Explanation: void * is the type for a generic pointer that can be converted to/from any object pointer.
Question 38. If int *p; int a[10];, which of the following assignments is valid? A) p = a; B) p = &a; C) p = a[0]; D) p = *a; Answer: A Explanation: In most expressions, an array decays to a pointer to its first element, so p = a; assigns int * correctly. Question 39. Which of the following correctly computes the number of elements in an array int data[20];? A) sizeof(data) / sizeof(int) B) sizeof(data) / sizeof(data[0]) C) sizeof(data[0]) * 20 D) sizeof(data) * 20 Answer: B Explanation: sizeof(data) gives total size; dividing by size of one element (data[0]) yields element count.
Question 40. In memory, where are static variables typically stored? A) Stack B) Heap C) Data segment (BSS or initialized data) D) Register Answer: C Explanation: Static storage duration variables reside in the program’s data segment, not on the stack or heap. Question 41. Which statement correctly uses the break keyword? A) break (i == 5); B) if (i == 5) break; C) break; inside a function body but outside any loop or switch. D) break; after a return statement. Answer: B Explanation: break terminates the nearest enclosing loop or switch. Placing it in an if inside a loop is valid.