Docsity

PrepIQ C Programming Language Certified Associate CLA Ultimate Exam, Exams of Technology

Toggle sidebar
bg1
PrepIQ C Programming Language
Certified Associate CLA Ultimate
Exam
**Question 1.** Which of the following is NOT a characteristic of a high-level
programming language?
A) Platform independence
B) Direct manipulation of hardware registers
C) Use of English-like syntax
D) Automatic memory management
Answer: B
Explanation: High-level languages abstract away hardware details; direct
register access is typical 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: The code generation phase converts the intermediate
representation into assembly code.
**Question 3.** Which header file must be included to use the `printf`
function?
A) `<stdlib.h>`
B) `<stdio.h>`
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download PrepIQ C Programming Language Certified Associate CLA Ultimate Exam and more Exams Technology in PDF only on Docsity!

Certified Associate CLA Ultimate

Exam

Question 1. Which of the following is NOT a characteristic of a high-level programming language? A) Platform independence B) Direct manipulation of hardware registers C) Use of English-like syntax D) Automatic memory management Answer: B Explanation: High-level languages abstract away hardware details; direct register access is typical 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: The code generation phase converts the intermediate representation into assembly code. Question 3. Which header file must be included to use the printf function? A) B)

Certified Associate CLA Ultimate

Exam

C) D) Answer: B Explanation: printf is declared in the Standard I/O header ``. Question 4. What is the output of the following code?

int main(){ printf("%c", 65); return 0; }

A) 65 B) A C) %c D) Compilation error Answer: B Explanation: The integer 65 corresponds to the ASCII character ‘A’, and %c prints a character. Question 5. Which of the following is a valid identifier in C? A) 2ndValue B) float C) _tempVar D) my-var

Certified Associate CLA Ultimate

Exam

A) The variable is defined in the same translation unit. B) The variable has automatic storage duration. C) The variable is defined in another file. D) The variable is constant. Answer: C Explanation: extern declares a variable that is defined elsewhere, enabling cross-file linkage. Question 9. Which of the following statements correctly defines a structure named Point with two integer members x and y? A) struct Point { int x, y; }; B) struct Point ( int x; int y; ); C) struct Point = { int x; int y; }; D) struct Point { int x; int y } Answer: A Explanation: The correct syntax uses braces and a semicolon after the definition. Question 10. How many bytes does sizeof(double) typically return on a modern 64-bit system? A) 2 B) 4 C) 8 D) 16

Certified Associate CLA Ultimate

Exam

Answer: C Explanation: On most 64-bit platforms, a double occupies 8 bytes. Question 11. Which of the following is a valid pointer declaration? A) int *p; B) int &amp;p; C) int p*; D) int **p; Answer: A Explanation: int *p; declares p as a pointer to an int. Option D is also valid but the question asks for “a” valid declaration; both A and D are valid, but A is the simplest correct choice. Question 12. What is the result of the expression 5 + 2 * 3 in C? A) 21 B) 11 C) 15 D) 9 Answer: B Explanation: Multiplication has higher precedence, so 2*3 = 6; then 5+ = 11. Question 13. Which operator has the highest precedence?

Certified Associate CLA Ultimate

Exam

Answer: D Explanation: sizeof can take either a type name (e.g., sizeof(int)) or an expression. Question 16. Given int a = 10; int *p = &amp;a;, what does *p = 20; accomplish? A) Changes p to point to a new address. B) Sets a to 20. C) Causes a compilation error. D) Leaves a unchanged. Answer: B Explanation: Dereferencing p accesses the object it points to, so a becomes 20. Question 17. Which of the following is the correct way to allocate memory for an array of 15 float elements using malloc? A) float *arr = malloc(15); B) float *arr = malloc(15 * sizeof(float)); C) float arr = malloc(15 * sizeof(float)); D) float *arr = (float)malloc(15 * sizeof(float)); Answer: B Explanation: malloc requires the total byte count; 15 * sizeof(float) provides that.

Certified Associate CLA Ultimate

Exam

Question 18. What does the macro #define SQR(x) ((x)*(x)) expand to when used as SQR(3+2)? A) (3+2)*(3+2) B) ((3+2)*(3+2)) C) (3+2*3+2) D) ((3)+(2))*((3)+(2)) Answer: B Explanation: The macro substitutes the argument verbatim, and the extra parentheses protect the intended order, yielding ((3+2)*(3+2)). Question 19. Which preprocessor directive prevents multiple inclusion of a header file named myhdr.h? A) #pragma once B) #include "myhdr.h" C) #define MYHDR_H D) #ifndef MYHDR_H Answer: D Explanation: The typical guard uses #ifndef MYHDR_H … #define MYHDR_H … #endif to avoid re-inclusion. Question 20. In C, what is the result of the relational expression 5 &gt; 3 &amp;&amp; 2 &lt; 1? A) 1 (true) B) 0 (false) C) Undefined behavior

Certified Associate CLA Ultimate

Exam

D) 0123

Answer: A Explanation: The loop prints i before it is incremented; values printed are 0, 1, 2. Question 23. Which loop construct guarantees that the body is executed at least once? A) while B) for C) do … while D) goto Answer: C Explanation: do … while evaluates the condition after executing the loop body. Question 24. In the statement continue; inside a for loop, what happens? A) The loop terminates completely. B) Control jumps to the next iteration after the increment expression. C) The program exits the current function. D) The loop variable is reset to zero. Answer: B Explanation: continue skips the remaining statements and proceeds with the loop’s iteration expression.

Certified Associate CLA Ultimate

Exam

Question 25. Which of the following function prototypes correctly declares a function that returns a pointer to int and takes no arguments? A) int * func(void); B) int func*(void); C) int *func(); D) int* func(void); Answer: A Explanation: int * func(void); explicitly specifies no parameters and a return type of int *. Option D is syntactically valid as well, but A follows the conventional style with space after the asterisk. Question 26. What is the effect of the register storage class? A) Forces the variable to be stored in a CPU register if possible. B) Makes the variable globally accessible. C) Prevents the variable from being initialized. D) Allows the variable to be used as an array index only. Answer: A Explanation: register hints to the compiler that the variable may be kept in a register for faster access. Question 27. Which of the following statements about const qualified variables is TRUE? A) A const variable can be modified through a pointer to non-const. B) const variables must be initialized at the point of definition.

Certified Associate CLA Ultimate

Exam

Explanation: strncpy limits the number of characters copied, preventing buffer overflow when used correctly. Question 30. What does the fgetc function return upon reaching end-of-file? A) 0 B) EOF C) NULL D) -1 Answer: B Explanation: fgetc returns the macro EOF (typically –1) to signal end-of-file or error. Question 31. Which of the following statements about static variables inside a function is FALSE? A) They retain their value between calls. B) They are initialized only once. C) They have block scope. D) They are stored on the heap. Answer: D Explanation: static variables have static storage duration, residing in the data segment, not on the heap. Question 32. Which of the following is the correct way to declare a function that takes a pointer to an array of 10 integers?

Certified Associate CLA Ultimate

Exam

A) void func(int (*arr)[10]); B) void func(int arr[10]); C) void func(int arr[]); D) void func(int *arr[10]); Answer: A Explanation: int (*arr)[10] declares a pointer to an array of 10 ints. Option B/ C decay to a pointer to int, losing the size information. Question 33. What is the result of the bitwise expression 0xF0 &amp; 0x0F? A) 0xFF B) 0x00 C) 0x0F D) 0xF0 Answer: B Explanation: The two nibbles have no overlapping set bits; the AND yields 0. Question 34. Which shift operator performs a logical left shift? A) &gt;&gt; B) &lt;&lt; C) &gt;&gt;&gt; D) &lt;&lt;&lt; Answer: B

Certified Associate CLA Ultimate

Exam

B) The variable may be changed by hardware or another thread. C) The variable must be stored in a register. D) The variable is constant. Answer: B Explanation: volatile prevents certain optimizations because the value can change unexpectedly. Question 38. Which of the following format specifiers is used to print a double value with printf? A) %f B) %lf C) %d D) %c Answer: A Explanation: In printf, %f prints both float and double. The l length modifier is ignored for printf. Question 39. Which of the following statements about the goto statement is TRUE? A) It is recommended for implementing loops. B) It can jump out of a function. C) It can only jump to a label within the same function. D) It automatically frees allocated memory.

Certified Associate CLA Ultimate

Exam

Answer: C Explanation: goto may only transfer control to a label in the same function; it cannot cross function boundaries. Question 40. What is the effect of the expression a ^= b;? A) a = a | b B) a = a &amp; b C) a = a ^ b (bitwise XOR) D) a = b Answer: C Explanation: The compound assignment ^= applies the bitwise XOR operator to a and b. Question 41. Which of the following statements correctly opens a file for reading in binary mode? A) FILE *fp = fopen("data.bin", "rb"); B) FILE *fp = fopen("data.bin", "r"); C) FILE *fp = fopen("data.bin", "wb"); D) FILE *fp = fopen("data.bin", "b"); Answer: A Explanation: "rb" specifies read access with binary mode. Question 42. What does the macro #define MAX(a,b) ((a) &gt; (b)? (a) : (b)) compute?

Certified Associate CLA Ultimate

Exam

Answer: D Explanation: In most contexts, the array name arr decays to a pointer to its first element, and &amp;arr[0] explicitly takes that address. Question 45. What is the result of the expression (~0U) &gt;&gt; 1 on a 32 - bit unsigned integer? A) 0x7FFFFFFF B) 0xFFFFFFFF C) 0x80000000 D) 0x00000000 Answer: A Explanation: ~0U yields all bits set (0xFFFFFFFF). Right shift by 1 produces 0x7FFFFFFF. Question 46. Which of the following is the correct way to declare a function that takes a variable number of arguments? A) int sum(int count, ...); B) int sum(int count); C) int sum(...); D) int sum(int, ...) Answer: A Explanation: The ellipsis (...) must follow at least one named parameter; int sum(int count, ...); is proper. Question 47. In the context of file I/O, what does the mode "a+" mean?

Certified Associate CLA Ultimate

Exam

A) Append only, binary. B) Read and write, starting at the beginning. C) Append and read, writing starts at the end. D) Write only, truncating the file. Answer: C Explanation: "a+" opens a file for reading and appending; writes occur at the end, but reading can occur anywhere. Question 48. Which of the following statements about the sizeof operator applied to a pointer is TRUE? A) It returns the size of the object pointed to. B) It returns the size of the pointer itself. C) It depends on the type of the pointed object. D) It is undefined behavior. Answer: B Explanation: sizeof(ptr) gives the size of the pointer variable (e.g., 8 bytes on a 64-bit system), regardless of the pointed type. Question 49. What is the output of the following code?

int a = 5; printf("%d %d", a, a++);

A) 5 5