Docsity

C Certified EntryLevel CLE Programmer Certification Ultimate Exam, Exams of Technology

Toggle sidebar
bg1
C Certified EntryLevel CLE
Programmer Certification
Ultimate Exam
Question 1. Which of the following best describes the main difference between a compiled
language like C and an interpreted language?
A) Compiled languages translate code line-by-line during runtime, while interpreted languages
translate the entire program before execution.
B) Compiled languages translate the entire source code into machine code before execution,
whereas interpreted languages translate and execute code line-by-line at runtime.
C) Compiled languages do not require a processor to execute, while interpreted languages run
directly on the hardware.
D) Compiled languages can only run on virtual machines, whereas interpreted languages are
limited to physical hardware.
Answer: B
Explanation: C is a compiled language where a compiler translates the source code into
machine code (object code) prior to execution. Interpreted languages rely on an interpreter to
parse and execute instructions on the fly during runtime.
Question 2. What is the primary purpose of the preprocessor phase in the compilation of a
C program?
A) To translate source code directly into machine-executable binary files.
B) To link compiled object files with library files to create an executable.
C) To handle directives starting with #, such as expanding macros and including header files,
before actual compilation begins.
D) To catch runtime errors and check for syntax mistakes in conditional statements.
Answer: C
Explanation: The preprocessor is the first phase of compilation. It processes directives starting
with '#' (like #include and #define) by substituting macros, expanding header files, and handling
conditional compilation before handing the modified code to the compiler.
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

Partial preview of the text

Download C Certified EntryLevel CLE Programmer Certification Ultimate Exam and more Exams Technology in PDF only on Docsity!

Programmer Certification

Ultimate Exam

Question 1. Which of the following best describes the main difference between a compiled language like C and an interpreted language? A) Compiled languages translate code line-by-line during runtime, while interpreted languages translate the entire program before execution. B) Compiled languages translate the entire source code into machine code before execution, whereas interpreted languages translate and execute code line-by-line at runtime. C) Compiled languages do not require a processor to execute, while interpreted languages run directly on the hardware. D) Compiled languages can only run on virtual machines, whereas interpreted languages are limited to physical hardware. Answer: B Explanation: C is a compiled language where a compiler translates the source code into machine code (object code) prior to execution. Interpreted languages rely on an interpreter to parse and execute instructions on the fly during runtime. Question 2. What is the primary purpose of the preprocessor phase in the compilation of a C program? A) To translate source code directly into machine-executable binary files. B) To link compiled object files with library files to create an executable. C) To handle directives starting with #, such as expanding macros and including header files, before actual compilation begins. D) To catch runtime errors and check for syntax mistakes in conditional statements. Answer: C Explanation: The preprocessor is the first phase of compilation. It processes directives starting with '#' (like #include and #define) by substituting macros, expanding header files, and handling conditional compilation before handing the modified code to the compiler.

Programmer Certification

Ultimate Exam

Question 3. Which component of the C compilation pipeline is responsible for combining compiled object files (.obj or .o) and resolving references to external library functions like printf()? A) Preprocessor B) Assembler C) Linker D) Compiler Answer: C Explanation: The linker is responsible for merging one or more object files and static libraries into a single executable file, resolving external references and memory symbols in the process. Question 4. What type of error is detected when a programmer accidentally omits a semicolon at the end of a variable declaration in a C source file? A) Linker error B) Runtime error C) Preprocessor warning D) Compiler error Answer: D Explanation: Omitting a semicolon violates the syntax rules of the C programming language. Syntax violations are caught by the compiler during the translation phase, resulting in a compilation/syntax error. Question 5. Which of the following errors is classified as a runtime error rather than a compilation or linker error? A) Attempting to call a function that has not been defined or linked. B) Writing 'prinf' instead of 'printf'.

Programmer Certification

Ultimate Exam

Explanation: The #include preprocessor directive instructs the preprocessor to locate the specified header file and literally copy-paste its declarations and definitions into the source stream. Question 8. Which of the following escape sequences is used to insert a horizontal tab in a printed string when using the printf() function? A) \n B) \t C) \r D) \b Answer: B Explanation: In C, the '\t' escape sequence represents a horizontal tab, shifting the text cursor to the next tab stop. '\n' represents a newline, '\r' a carriage return, and '\b' a backspace. Question 9. What is the output generated by the statement: printf("Hello\nWorld");? A) Hello World B) Hello\nWorld C) Hello World D) Hello World (with an indented second line) Answer: B Explanation: The backslash '' is the escape character in C. To print a literal backslash, you must escape it with another backslash (""). Thus, "\n" prints the literal characters '' and 'n' instead of a newline.

Programmer Certification

Ultimate Exam

Question 10. How is the decimal value 25 represented in the hexadecimal numeral system within C code? A) 0x B) 0x C) 031 D) 0b Answer: A Explanation: Hexadecimal is base 16. The decimal value 25 is equivalent to 16 * 1 + 9, which is represented as 19 in hex. In C, hexadecimal literals are prefixed with "0x" or "0X", making it 0x19. Question 11. What is the decimal value of the octal literal 037 in C? A) 37 B) 31 C) 29 D) 45 Answer: B Explanation: In C, any integer literal starting with a leading zero '0' (and not followed by 'x' or 'b') is interpreted as an octal number (base 8). The octal value 037 equals (3 * 8^1) + (7 * 8^0) = 24 + 7 = 31. Question 12. Which of the following represents the binary number 1011 in its decimal equivalent? A) 11 B) 13 C) 9

Programmer Certification

Ultimate Exam

Question 15. What is the fundamental difference between 'signed' and 'unsigned' integer modifiers in C? A) 'signed' variables can store floating-point values, while 'unsigned' variables cannot. B) 'signed' variables reserve the most significant bit as a sign bit to store both positive and negative numbers, while 'unsigned' variables use all bits to store only non-negative values. C) 'unsigned' variables occupy twice as much memory space as 'signed' variables. D) 'signed' variables are evaluated only at compile time, whereas 'unsigned' variables are evaluated at runtime. Answer: B Explanation: The 'signed' modifier allows a variable to hold both positive and negative values by using the sign bit (usually via two's complement). The 'unsigned' modifier treats all bits as magnitude, shifting the range of representable numbers to exclusively positive values and zero. Question 16. Which of the following is a valid integer literal representing the value 100 in decimal? A) 100. B) 0x C) 0144 D) 0x Answer: B Explanation: The hexadecimal value 0x64 is calculated as (6 * 16) + 4 = 96 + 4 = 100 in decimal. '100.0' is a floating-point literal, '0144' in octal is (1 * 64) + (4 * 8) + 4 = 100, but 0x in hexadecimal is 256. Thus, 0x64 represents 100 decimal. Question 17. How is the floating-point scientific notation literal '2.5e-3' represented as a standard decimal value? A) 2500.

Programmer Certification

Ultimate Exam

B) 0.

C) 0.

D) -2500.

Answer: C Explanation: Scientific notation 'e-3' represents multiplying the significand by 10 to the power of -3 (10^-3). Therefore, 2.5 * 10^-3 = 0.0025. Question 18. Which of the following is an invalid identifier in C? A) totalSum B) count_2 C) 2ndValue D) mainValue Answer: C Explanation: C identifiers (variable, function, or label names) must begin with a letter (a-z, A-Z) or an underscore ( ). They cannot begin with a digit (0-9). Question 19. What is the difference between declaring a variable and initializing a variable? A) Declaring a variable assigns it a value, whereas initializing it allocates memory. B) Declaring a variable specifies its type and name to the compiler, while initializing it allocates the initial value to the allocated memory. C) Declaring is done at runtime, whereas initializing is done only at compile time. D) Declaring can only be done inside main(), while initializing must be done outside functions. Answer: B Explanation: Declaration tells the compiler about the existence, name, and data type of a variable. Initialization is the process of assigning an initial value to that variable for the first time. Question 20. Which format specifier should be used in the printf() function to print a signed decimal integer? A) %f B) %c

Programmer Certification

Ultimate Exam

Explanation: In "%8.2f", '8' is the minimum field width (the total number of characters printed, padded with spaces if necessary), and '.2' is the precision (the number of digits displayed after the decimal point). Question 23. What is the correct way to define a read-only variable in C using the const keyword? A) #define const int MAX = 100; B) int MAX const = 100; C) const int MAX = 100; D) const MAX = 100; Answer: C Explanation: The 'const' qualifier is applied to a variable declaration to make its value unmodifiable after initialization. The standard syntax is 'const data_type identifier = value;'. Question 24. What is a key difference between defining a constant using '#define' versus using the 'const' keyword? A) '#define' constants occupy physical RAM space, while 'const' variables do not. B) '#define' is processed by the preprocessor as a literal text substitution and has no type safety, whereas 'const' defines typed variables checked by the compiler. C) 'const' variables can be reassigned anywhere in the program, while '#define' macros cannot. D) '#define' can only represent floating-point values, while 'const' can only represent characters. Answer: B Explanation: '#define' is a preprocessor macro directive that performs literal textual replacement before compilation begins, offering no type checking. 'const' variables are actual typed variables managed by the compiler, adhering to scoping and type rules. Question 25. Given the expression 'int result = 15 % 4;', what value is assigned to the variable 'result'?

Programmer Certification

Ultimate Exam

A) 3

B) 2

C) 1

D) 0

Answer: A Explanation: The modulo operator '%' returns the remainder of integer division. 15 divided by 4 is 3 with a remainder of 3. Therefore, 'result' is assigned 3. Question 26. What is the resulting value of the expression '17 / 5' when evaluated in a C program using standard integer arithmetic? A) 3. B) 3 C) 4 D) 0 Answer: B Explanation: When both operands of the division operator '/' are integers, C performs integer division, truncating the fractional part and returning only the whole number. Thus, 17 / 5 evaluates to 3. Question 27. If 'int x = 10;', what is the value of 'x' after executing the statement 'x += 5 * 2;'? A) 30 B) 20 C) 15 D) 25

Programmer Certification

Ultimate Exam

A) 5 == 6

B)!

C) 3 && 0

D) 5 != 6

Answer: D Explanation: The relational inequality operator '!=' returns true (1) if the operands are not equal. Since 5 is not equal to 6, '5 != 6' evaluates to true (1). '!10' is 0, '3 && 0' is 0, and '5 == 6' is 0. Question 31. What is the output of the expression '5 && 10' in a conditional check? A) 0 B) 1 C) 50 D) 15 Answer: B Explanation: In C, any non-zero value is treated as logical true. Since both 5 and 10 are non- zero (true), the logical AND operator (&&) evaluates to true, which is represented by the integer value 1. Question 32. Which operator is used to perform a logical NOT operation in C? A) ~ B)! C) & D) | Answer: B

Programmer Certification

Ultimate Exam

Explanation: The logical NOT operator is represented by '!'. The tilde '~' is the bitwise NOT (one's complement) operator. Question 33. Given 'unsigned char x = 5; unsigned char y = 9;', what is the result of the bitwise AND operation 'x & y'? A) 1 B) 0 C) 13 D) 14 Answer: A Explanation: The binary representation of 5 is 0101, and 9 is 1001. Performing a bitwise AND: 0101 & 1001 = 0001 (which is 1 in decimal). Question 34. What is the effect of the bitwise left shift operation 'x << 2' on an integer variable 'x' containing the value 3? A) It divides the value of x by 4. B) It shifts the bits of x left by two positions, resulting in a value of 12. C) It sets the first two bits of x to zero, resulting in 1. D) It converts the value of x to 9. Answer: B Explanation: Shifting an integer left by 'n' bits is equivalent to multiplying it by 2^n. Thus, 3 << 2 is equal to 3 * 2^2 = 12. In binary, 0011 shifted left by two becomes 1100 (12).

Programmer Certification

Ultimate Exam

D) () (parentheses/function call) Answer: D Explanation: Parentheses '()' have the highest precedence among the listed operators, ensuring expressions within them are evaluated first. Question 38. In the expression 'a + b * c', how is the evaluation order determined? A) Left-to-right associativity dictates 'a + b' is calculated first. B) Operator precedence dictates 'b * c' is calculated first because ' ' has higher precedence than '+'. C) Assignment operators dictate '+' is evaluated first. D) The compiler chooses the order randomly based on optimization flags. Answer: B Explanation: Multiplication ' ' has a higher operator precedence than addition '+', meaning 'b * c' is evaluated first, and its result is then added to 'a'. Question 39. What is the output of the following code snippet? int x = 5; if (x = 0) { printf("True"); } else { printf("False"); } A) True B) False C) Compilation Error D) Runtime Error Answer: B Explanation: The expression 'x = 0' inside the if-condition is an assignment, not a comparison ('=='). It assigns 0 to 'x' and returns 0, which evaluates to logical false in C. Thus, the else block executes and prints "False". Question 40. What is the structure of an else-if ladder used for in conditional execution? A) To create infinite loops. B) To execute multiple matching blocks simultaneously.

Programmer Certification

Ultimate Exam

C) To test multiple conditions sequentially until one matches, executing only that corresponding block. D) To declare variables of different scopes. Answer: C Explanation: An else-if ladder evaluated conditions sequentially from top to bottom. As soon as one of the conditions is found to be true, the block associated with it is executed, and the remainder of the ladder is bypassed. Question 41. In a switch statement, what happens if a matching case is found but does not contain a 'break' statement at the end? A) The program halts with a runtime exception. B) The program exits the switch block immediately. C) The execution falls through to the next sequential case statement, executing its code regardless of whether the next case's value matches. D) The switch statement restarts from the default case. Answer: C Explanation: Without a 'break' statement, execution continues (falls through) to the subsequent cases sequentially until a break is encountered or the switch block ends. Question 42. Which data types are permitted to be used as the controlling expression in a C switch statement? A) float and double B) Only pointers C) Integral types (such as int and char) D) Any structure or array Answer: C

Programmer Certification

Ultimate Exam

B) A while loop checks its condition at the beginning of the iteration, while a do-while loop evaluates its condition at the end of the iteration, guaranteeing it executes at least once. C) A do-while loop is only used for infinite execution. D) A while loop does not support the break statement. Answer: B Explanation: A 'while' loop evaluates the condition first; if false, the body never runs. A 'do- while' loop runs the body first, and then checks the condition, ensuring the loop body executes at least once. Question 46. What is the output of the following loop? int i = 0; while (i < 3) { printf("%d", i); i++; } A) 012 B) 123 C) 0123 D) 0 Answer: A Explanation: The loop initializes 'i' to 0. It prints 'i' and increments it. Iteration 1: i = 0, prints 0, i becomes 1. Iteration 2: i = 1, prints 1, i becomes 2. Iteration 3: i = 2, prints 2, i becomes 3. At i = 3, the condition (3 < 3) is false, and the loop terminates. Question 47. In a 'for' loop statement, what is the sequence of execution for the three expression components? (for (expr1; expr2; expr3)) A) expr1 is run once, expr2 is evaluated before each loop body execution, and expr3 is run after each loop body execution.

Programmer Certification

Ultimate Exam

B) expr1, expr2, and expr3 are all executed once before entering the loop. C) expr2 is evaluated first, then expr1, then expr3. D) expr3 is evaluated before the loop body, and expr2 is evaluated after. Answer: A Explanation: In a 'for' loop, the first expression (initialization) is executed once at the start. The second expression (condition) is evaluated before each iteration. The third expression (increment/modification) is executed at the end of each iteration, after the loop body runs. Question 48. What is the effect of the 'continue' statement when executed inside a loop? A) It terminates the loop entirely. B) It restarts the entire program from main(). C) It skips the remaining statements in the current iteration of the loop and jumps directly to the loop's condition evaluation (or increment expression). D) It pauses execution for a brief period. Answer: C Explanation: The 'continue' statement halts the current iteration of a loop and transfers control to the next iteration (specifically the loop control condition check in a while/do-while, or the update expression in a for loop). Question 49. What is the effect of the 'break' statement when executed inside a loop? A) It exits the entire function containing the loop. B) It terminates the execution of the innermost loop immediately and transfers control to the statement following the loop. C) It skips to the next iteration of the loop. D) It re-initializes all loop control variables to zero. Answer: B