Docsity

PrepIQ CLE C Certified Entry Level Programmer Ultimate Exam, Exams of Technology

Toggle sidebar
bg1
PrepIQ CLE C Certified Entry
Level Programmer Ultimate
Exam
**Question 1. Which component of the C compilation process replaces macro
definitions with their corresponding code before actual compilation?**
A) Assembler
B) Linker
C) Preprocessor
D) Loader
Answer: C
Explanation: The preprocessor handles directives like #define, expanding macros
before the compiler translates the source code.
**Question 2. In a standard C program, which function must be present for the
program to have an entry point?**
A) start()
B) init()
C) main()
D) entry()
Answer: C
Explanation: The C runtime looks for the function named main() as the program’s
starting point.
**Question 3. Which of the following header files is required to use the printf()
function?**
A) <stdlib.h>
B) <stdio.h>
C) <string.h>
D) <math.h>
Answer: B
Explanation: printf() is declared in the Standard I/O header <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

Partial preview of the text

Download PrepIQ CLE C Certified Entry Level Programmer Ultimate Exam and more Exams Technology in PDF only on Docsity!

Level Programmer Ultimate

Exam

Question 1. Which component of the C compilation process replaces macro definitions with their corresponding code before actual compilation? A) Assembler B) Linker C) Preprocessor D) Loader Answer: C Explanation: The preprocessor handles directives like #define, expanding macros before the compiler translates the source code. Question 2. In a standard C program, which function must be present for the program to have an entry point? A) start() B) init() C) main() D) entry() Answer: C Explanation: The C runtime looks for the function named main() as the program’s starting point. Question 3. Which of the following header files is required to use the printf() function? A) B) C) D) Answer: B Explanation: printf() is declared in the Standard I/O header .

Level Programmer Ultimate

Exam

Question 4. What does the ANSI C standard primarily ensure for C programs? A) Faster execution B) Platform-specific extensions C) Source code portability across conforming compilers D) Automatic memory management Answer: C Explanation: ANSI C defines a common language specification, allowing code to compile on any conforming system. Question 5. Which of the following is a signed 16-bit integer type on most modern compilers? A) unsigned short B) long int C) short int D) unsigned int Answer: C Explanation: short int is typically a 16-bit signed integer; unsigned short is the unsigned variant. Question 6. Which literal represents the floating-point number 3.14 in scientific notation? A) 3.14e B) 3.14f C) 3.14d D) 3.14L Answer: A Explanation: The suffix “e0” denotes exponent 0, so 3.14e0 equals 3.14.

Level Programmer Ultimate

Exam

Question 10. Which increment operator yields the value of the variable before it is increased? A) ++x B) x++ C) ++(x) D) (x)++ Answer: B Explanation: Postfix ++ returns the original value, then increments the variable. Question 11. In the logical expression (a && b), if a evaluates to false, what happens to b? A) b is evaluated first B) b is evaluated after a C) b is not evaluated (short-circuit) D) Both are always evaluated Answer: C Explanation: && uses short-circuit evaluation; if the first operand is false, the whole expression is false, so b is skipped. Question 12. Which bitwise operator flips every bit of its operand? A) & B) | C) ^ D) ~ Answer: D Explanation: The tilde (~) is the bitwise NOT operator, producing the one's complement of the operand.

Level Programmer Ultimate

Exam

Question 13. What is the precedence relationship between the operators * (multiplication) and + (addition) in C? A) * has higher precedence than + B) + has higher precedence than * C) Both have the same precedence D) Precedence is determined at runtime Answer: A Explanation: Multiplication and division have higher precedence than addition and subtraction. Question 14. Which relational operator tests for “greater than or equal to”? A) > B) < C) >= D) <= Answer: C Explanation: >= means “greater than or equal to”. Question 15. Which statement correctly implements a multi-way branch for the variable grade? A) if (grade == 'A') … else if … B) switch (grade) { case 'A': … break; default: … } C) while (grade) { … } D) for (grade; ; ) { … } Answer: B Explanation: switch supports multiple case labels and a default clause, ideal for handling distinct constant values like grades.

Level Programmer Ultimate

Exam

A) while (i < 10) { i++; } B) for ( ; ; ) { printf("hi"); } C) do { i++; } while (i == 5); D) if (x) break; Answer: B Explanation: A for loop with empty initialization, condition, and increment parts never terminates. Question 20. How many elements does the array declaration int nums[5]; allocate? A) 4 B) 5 C) 6 D) Undefined Answer: B Explanation: The size inside brackets specifies the number of elements; here, five ints. Question 21. Which statement correctly initializes all elements of an integer array to zero? A) int a[10] = {0}; B) int a[10] = {NULL}; C) int a[10] = {‘0’}; D) int a[10] = {0,0,0,0,0,0,0,0,0,0,0}; Answer: A Explanation: Initializing the first element to 0 and omitting the rest causes the compiler to zero-initialize the entire array.

Level Programmer Ultimate

Exam

Question 22. What is the result of the expression *(p + 2) where p is a pointer to the first element of an int array? A) The value of the second element B) The address of the third element C) The value of the third element D) Compilation error Answer: C Explanation: Pointer arithmetic adds 2sizeof(int) to the address; dereferencing yields the third element’s value. Question 23. Which operator yields the memory address of a variable? A) * B) & C) -> D). Answer: B Explanation: The address-of operator (&) returns the variable’s location in memory. Question 24. Which of the following statements correctly declares a pointer to a function that returns int and takes two int arguments? A) int (fp)(int, int); B) int fp(int, int); C) int fp(int, int); D) int fp(int, int); Answer: A Explanation: The syntax int (*fp)(int, int); defines fp as a pointer to a function returning int and accepting two int parameters.

Level Programmer Ultimate

Exam

A) 4

B) 5

C) 6

D) Undefined Answer: B Explanation: strlen counts characters before the terminating null; “Hello” has five characters. Question 29. Which function copies a source string into a destination buffer, assuming the destination is large enough? A) strcat() B) strcpy() C) strcmp() D) strncat() Answer: B Explanation: strcpy copies the entire source string, including the terminating null, into the destination. Question 30. What will strcmp("abc", "abd") return? A) 0 B) Positive value C) Negative value D) Undefined Answer: C Explanation: strcmp returns a negative value when the first differing character in the first string is less than that in the second (“c” < “d”). Question 31. Which prototype correctly declares a function named max that takes two int arguments and returns an int?

Level Programmer Ultimate

Exam

A) void max(int a, int b); B) int max(int a, int b); C) int max(void); D) double max(int a, int b); Answer: B Explanation: The return type int matches the description, and the parameter list matches the two int arguments. Question 32. When a function parameter is declared as int *p, how is the argument passed? A) By value (copy of the integer) B) By reference (address of an integer) C) By name D) As a constant Answer: B Explanation: Declaring a parameter as a pointer means the caller passes the address of an int, allowing the function to modify the original variable. Question 33. Which storage class specifier gives a variable internal linkage, limiting its visibility to the translation unit? A) extern B) static C) auto D) register Answer: B Explanation: static at file scope makes the identifier have internal linkage, visible only within that source file. **Question 34. What is the output of the following code?

Level Programmer Ultimate

Exam

Explanation: The ?: construct selects c if b is true, otherwise d; it is the ternary conditional operator. Question 37. Which of the following is a correct way to declare a constant integer with value 10? A) const int MAX = 10; B) int const MAX = 10; C) #define MAX 10 D) All of the above Answer: D Explanation: All three methods create a constant named MAX with value 10: const qualifier, const after type, or macro definition. Question 38. Which of these statements correctly disables warnings about unused variables without affecting program behavior? A) (void)unusedVar; B) #pragma warning(disable: 4100) C) unusedVar = 0; D) delete unusedVar; Answer: A Explanation: Casting the variable to void explicitly marks it as intentionally unused. Question 39. What is the size (in bytes) of the type long long on a typical 64-bit system? A) 4 B) 8 C) 16 D) Implementation-defined Answer: B

Level Programmer Ultimate

Exam

Explanation: On most modern 64-bit platforms, long long occupies 8 bytes. Question 40. Which of the following expressions yields true if variable x is between 10 and 20 inclusive? A) x > 10 && x < 20 B) x >= 10 && x <= 20 C) 10 <= x <= 20 D) (x >= 10) | (x <= 20) Answer: B Explanation: Using && with inclusive comparisons correctly checks the range. **Question 41. What does the following macro do?

#define SQUARE(x) ((x)*(x))

A) Computes the square of x safely even when x is an expression B) Computes the cube of x C) Causes a compilation error D) Returns the absolute value of x Answer: A** Explanation: The macro expands to ((x)*(x)), preserving operator precedence and allowing any expression as argument. Question 42. Which of these statements about the enum type is correct? A) Enumerators are of type int by default. B) Enumerators can have floating-point values. C) An enum can contain duplicate names. D) Enum values are automatically stored as strings.

Level Programmer Ultimate

Exam

Explanation: sizeof yields the compile-time size of the pointer type, not the pointed-to object. **Question 46. Which function from `` converts a string to a long integer? ** A) atoi() B) atol() C) itoa() D) ltoa() Answer: B Explanation: atol() parses a null-terminated string and returns its value as a long. Question 47. In C, which of the following is true about the order of evaluation of function arguments? A) Left-to-right is guaranteed. B) Right-to-left is guaranteed. C) The order is unspecified. D) Arguments are evaluated in parallel. Answer: C Explanation: The C standard does not define the order in which function arguments are evaluated. Question 48. 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

Level Programmer Ultimate

Exam

Explanation: Mode "rb" means read binary; “r” is text mode, “wb” is write binary. Question 49. What does the expression *ptr++ do? A) Increments the pointer, then dereferences the new address B) Dereferences the pointer, then increments the pointer C) Increments the value pointed to, leaving the pointer unchanged D) Causes a compilation error Answer: B Explanation: Postfix ++ has higher precedence than *, so the pointer is dereferenced first, then the pointer is incremented. Question 50. Which of the following statements about const qualified pointers is correct? A) int * const p makes the pointer itself constant, not the data pointed to. B) const int * p makes the pointed-to data constant, not the pointer. C) Both A and B are correct. D) Neither A nor B is correct. Answer: C Explanation: int * const p cannot change the address stored in p; const int * p cannot modify the integer through p. Question 51. Which of the following expressions yields true if exactly one of the two boolean variables a and b is true? A) a && b B) a || b C) a ^ b D) !(a && b) Answer: C

Level Programmer Ultimate

Exam

Explanation: Both #pragma once and the traditional include guard pattern prevent multiple inclusion. **Question 55. What will be printed by the following code?

int a = 10; printf("%#x", a);

A) 0xa B) a C) 10 D) 0x Answer: A** Explanation: The # flag with %x prefixes the hexadecimal output with 0x. Question 56. Which of the following is the correct prototype for a function that takes no arguments and returns no value? A) void func(void); B) void func(); C) int func(void); D) Both A and B are acceptable. Answer: D Explanation: In C, both void func(void); and void func(); declare a function with no parameters; the former is explicit. Question 57. Which of the following statements about static local variables is true? A) They are reinitialized each time the function is called. B) Their lifetime extends for the duration of the program.

Level Programmer Ultimate

Exam

C) They have external linkage. D) They cannot be initialized. Answer: B Explanation: A static local variable retains its value between calls and exists for the whole program execution. Question 58. What is the result of the expression (~0U) &gt;&gt; 1 on a typical 32-bit unsigned int? A) 0x7FFFFFFF B) 0xFFFFFFFF C) 0x D) 0x Answer: A Explanation: ~0U yields all 1 bits (0xFFFFFFFF). Right shift by 1 produces 0x7FFFFFFF. Question 59. Which of the following statements correctly copies the first 5 characters from src to dest without appending a null terminator? A) strncpy(dest, src, 5); B) memcpy(dest, src, 5); C) strcpy(dest, src); D) strncat(dest, src, 5); Answer: B Explanation: memcpy copies a specific number of bytes regardless of null terminators; strncpy may pad with nulls, but still writes a null if space permits. Question 60. When using scanf("%d", &amp;x);, what must be true about the variable x? A) It must be a pointer to int.