Docsity

Programming Language Certified Associate Certification Study Guide [CLA], Exams of Technology

Toggle sidebar
bg1
Programming Language Certified Associate
Certification Study Guide [CLA]
**Question 1.** Which of the following is the correct order of phases performed by a typical C
compiler?
A) Linking → Preprocessing → Compiling → Loading
B) Preprocessing → Compiling → Linking → Loading
C) Compiling → Preprocessing → Linking → Loading
D) Preprocessing → Linking → Compiling → Loading
Answer: B
Explanation: The standard compilation pipeline is preprocessing, compiling, linking, and finally
loading the executable into memory.
**Question 2.** In C, which identifier is a valid variable name?
A) 2ndValue
B) _temp
C) float
D) total-value
Answer: B
Explanation: Identifiers may start with an underscore or a letter; they cannot start with a digit,
be a keyword, or contain hyphens.
**Question 3.** What is the size of the type `long long int` on a typical 64‑bit system?
A) 2 bytes
B) 4 bytes
C) 8 bytes
D) 16 bytes
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 Programming Language Certified Associate Certification Study Guide [CLA] and more Exams Technology in PDF only on Docsity!

Certification Study Guide [CLA]

Question 1. Which of the following is the correct order of phases performed by a typical C compiler? A) Linking → Preprocessing → Compiling → Loading B) Preprocessing → Compiling → Linking → Loading C) Compiling → Preprocessing → Linking → Loading D) Preprocessing → Linking → Compiling → Loading Answer: B Explanation: The standard compilation pipeline is preprocessing, compiling, linking, and finally loading the executable into memory. Question 2. In C, which identifier is a valid variable name? A) 2ndValue B) _temp C) float D) total-value Answer: B Explanation: Identifiers may start with an underscore or a letter; they cannot start with a digit, be a keyword, or contain hyphens. Question 3. What is the size of the type long long int on a typical 64‑bit system? A) 2 bytes B) 4 bytes C) 8 bytes D) 16 bytes

Certification Study Guide [CLA]

Answer: C Explanation: On most modern 64‑bit platforms, long long int is defined as an 8‑byte (64‑bit) integer. Question 4. Which literal represents an octal integer value of 83 decimal? A) 0x B) 0123 C) 0b D) 083 Answer: B Explanation: Octal literals begin with a leading 0; 0123₈ = 1·64 + 2·8 + 3 = 83₁₀. Question 5. What is the result of the expression 5 / 2 in C? A) 2. B) 2 C) 3 D) 2. Answer: B Explanation: Both operands are integers, so integer division is performed, discarding the fractional part. Question 6. Which operator has the highest precedence? A) * (multiplication)

Certification Study Guide [CLA]

Question 9. Which relational operator tests for “greater than or equal to”? A) > B) < C) >= D) == Answer: C Explanation: >= returns true when the left operand is greater than or equal to the right operand. Question 10. What does the bitwise operator ~ do to its operand? A) Shifts left by one bit B) Shifts right by one bit C) Inverts all bits (one’s complement) D) Performs logical NOT Answer: C Explanation: The tilde operator flips each bit, producing the one's complement of the operand. Question 11. Which of the following statements causes an implicit conversion from int to float? A) float f = 3; B) int i = (int)3.5; C) double d = (double)5; D) char c = 65;

Certification Study Guide [CLA]

Answer: A Explanation: Assigning an integer literal to a float variable triggers implicit conversion (promotion) to floating‑point. Question 12. Which control structure guarantees that the body is executed at least once? A) if B) while C) do … while D) for Answer: C Explanation: The do … while loop evaluates its condition after executing the body, ensuring one execution. Question 13. What is the output of the following code?

int x = 0; if (x) printf("A"); else printf("B");

A) A B) B C) No output D) Compilation error

Certification Study Guide [CLA]

A) return; B) break; C) continue; D) goto label; Answer: B Explanation: break terminates the nearest enclosing loop or switch. Question 17. What is the purpose of the goto statement? A) To create a function call B) To jump to a labeled statement within the same function C) To terminate the program D) To allocate dynamic memory Answer: B Explanation: goto transfers control to a label defined elsewhere in the same function. Question 18. Which declaration defines an array of 10 integers? A) int arr[10]; B) int arr = 10; C) int arr(10); D) int *arr[10]; Answer: A Explanation: int arr[10]; creates a contiguous block of 10 int elements.

Certification Study Guide [CLA]

Question 19. What is the result of sizeof(char) in C? A) 0 B) 1 C) 2 D) Implementation‑defined Answer: B Explanation: The C standard guarantees that sizeof(char) is 1 byte. Question 20. Which statement correctly initializes a two‑dimensional array of size 3×2? A) int a[3][2] = {{1,2},{3,4},{5,6}}; B) int a[3][2] = {1,2,3,4,5,6}; C) int a[3][2] = {{1,2,3},{4,5,6}}; D) int a[3][2] = {{1},{2},{3}}; Answer: A Explanation: Each inner brace initializes a row; the dimensions match the initializer list. Question 21. Which expression correctly obtains the address of variable x? A) &x B) *x C) x& D) #x

Certification Study Guide [CLA]

```

A) vp is a pointer to a function returning void B) vp is a pointer to an unknown type C) vp is a pointer to a void value (cannot be dereferenced) D) Both B and C Answer: D Explanation: void * is a generic pointer; it can hold the address of any object type but cannot be directly dereferenced without casting. Question 25. Which statement correctly declares a pointer to a pointer to int? A) int **pp; B) int *pp*; C) int &pp; D) int *&pp; Answer: A Explanation: int **pp; declares pp as a pointer to a pointer that ultimately points to an int. Question 26. Which standard library function copies a null‑terminated string from source to destination? A) strlen() B) strcat() C) strcpy() D) strcmp()

Certification Study Guide [CLA]

Answer: C Explanation: strcpy(dest, src) copies the source string, including the terminating null character, into the destination buffer. Question 27. What does strlen("Hello") return? A) 4 B) 5 C) 6 D) Undefined Answer: B Explanation: The length of “Hello” is 5 characters; the terminating null is not counted. Question 28. Which function concatenates two strings, storing the result in the first argument? A) strcat() B) strcpy() C) strncat() D) strcmp() Answer: A Explanation: strcat(dest, src) appends src to the end of dest. Question 29. Which of the following correctly declares a structure named Point with members x and y of type int? A) struct Point { int x; int y; };

Certification Study Guide [CLA]

Explanation: static applied to a global variable limits its visibility to the file (internal linkage). Question 32. What is the effect of the register keyword on a variable? A) Forces allocation on the heap B) Suggests storage in a CPU register for faster access C) Makes the variable read‑only D) Gives the variable external linkage Answer: B Explanation: register hints to the compiler that the variable may be kept in a register; the compiler may ignore it. Question 33. Which function allocates memory for an array of 10 int elements and initializes them to zero? A) malloc(10 * sizeof(int)) B) calloc(10, sizeof(int)) C) realloc(NULL, 10 * sizeof(int)) D) alloca(10 * sizeof(int)) Answer: B Explanation: calloc allocates and zero‑initializes the requested memory. Question 34. After calling malloc, which function must eventually be called to avoid a memory leak? A) calloc B) realloc

Certification Study Guide [CLA]

C) free D) memset Answer: C Explanation: free(ptr) releases the dynamically allocated block back to the heap. Question 35. Which of the following statements about realloc is true? A) It can shrink or grow an existing allocation B) It always returns the same pointer value C) It can be used on memory allocated with calloc only D) It does not preserve the original contents Answer: A Explanation: realloc may move the block but copies the existing data up to the lesser of old and new sizes. Question 36. Which prototype correctly declares a function that takes a pointer to int and returns void? A) void func(int *p); B) int func(void *p); C) void func(int p); D) void *func(int *p); Answer: A Explanation: The return type is void, and the parameter is a pointer to int.

Certification Study Guide [CLA]

Answer: A Explanation: The recursion must stop when n reaches 0, returning 1, which is the mathematical definition of 0!. Question 40. Which preprocessor directive includes the standard I/O header? A) #include B) #include "stdio.h" C) #import D) #using Answer: A Explanation: Angle brackets tell the compiler to search system include directories for stdio.h. Question 41. What does the macro definition #define SQUARE(x) ((x)*(x)) prevent? A) Division by zero B) Multiple evaluation of x C) Integer overflow D) Syntax errors Answer: B Explanation: By parenthesizing x and the whole expression, the macro avoids unintended operator precedence and multiple evaluations. Question 42. Which conditional compilation directive checks whether the macro DEBUG is defined?

Certification Study Guide [CLA]

A) #if DEBUG B) #ifdef DEBUG C) #ifndef DEBUG D) #elif DEBUG Answer: B Explanation: #ifdef tests if a macro name has been defined. Question 43. In a macro, what does the ## operator do? A) Stringizes its argument B) Concatenates two tokens C) Performs arithmetic addition D) Expands to a comment Answer: B Explanation: The token‑pasting operator ## joins two preprocessing tokens into a single token. Question 44. Which function reads a line of text from a file into a buffer, stopping after a newline or EOF? A) fgets() B) fgetc() C) fread() D) scanf() Answer: A

Certification Study Guide [CLA]

D) printf() Answer: A Explanation: fputc(ch, stream) writes the character ch to the specified stream. Question 48. Which of the following correctly checks for end‑of‑file when reading with fgetc? A) while ((c = fgetc(fp)) != EOF) { … } B) while (!feof(fp)) { c = fgetc(fp); … } C) while (feof(fp)) { … } D) while (c = fgetc(fp)) { … } Answer: A Explanation: fgetc returns EOF when the end of the file is reached; comparing directly is the reliable method. Question 49. What is the purpose of stdin? A) It is a macro for standard input file descriptor B) It is a FILE* object representing the console input stream C) It is a function that reads a character D) It is a constant integer value Answer: B Explanation: stdin is a predefined FILE* pointing to the standard input stream. Question 50. Which statement correctly closes a file opened with fopen?

Certification Study Guide [CLA]

A) close(fp); B) fclose(fp); C) delete(fp); D) remove(fp); Answer: B Explanation: fclose flushes buffers and releases the file descriptor. Question 51. What does the expression sizeof(int *) evaluate to on a 64‑bit system? A) 2 bytes B) 4 bytes C) 8 bytes D) Depends on the compiler Answer: C Explanation: On a typical 64‑bit architecture, a pointer occupies 8 bytes. Question 52. Which of the following is a valid way to define a macro that computes the minimum of two numbers? A) #define MIN(a,b) ((a)<(b)?(a):(b)) B) `#define MIN(a,b) a