Computer Knowledge

Programming Fundamentals

2,381 Questions

Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.

Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references

Programming Fundamentals Questions

Multiple choice
  1. Traversing

  2. Searching

  3. Merging

  4. None of these

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Traversing (visiting each element), searching (finding specific elements), and merging (combining structures) are all valid, fundamental data structure operations. Since all options A-C are valid operations, the correct answer is D - 'None of these' represents that there is no invalid operation in the list.

Multiple choice
  1. frame check sequence

  2. error detecting code

  3. checksum

  4. flow control

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Frame Check Sequence (FCS) is the error-detecting code added to data frames at the data link layer. It uses mechanisms like CRC (Cyclic Redundancy Check) to detect transmission errors. Checksum is a specific type of error-detecting code, but FCS is the broader, more accurate term for the field in network frames. Flow control is a separate function for managing data transmission rates, not error detection.

Multiple choice
  1. does not permit IF-THEN GOTO statement

  2. may have all the program statements that have a single entry point and a single exit point

  3. both (1) and (2)

  4. neither (1) nor (2)

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Structured programming languages minimize or eliminate GOTO statements in favor of control structures like if-then-else and loops. They emphasize single entry and exit points for program blocks to improve code readability and maintainability. Both statements correctly describe key principles of structured programming.

Multiple choice
  1. Loops

  2. GOTO statements

  3. Do-While statements

  4. All of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Structured programming is a programming paradigm that aims to improve code clarity and quality by reducing the use of GOTO statements. Instead, it uses control structures like loops (for, while), conditionals (if-then-else), and subroutines. The absence of GOTO statements is a defining characteristic of structured programming.

Multiple choice
  1. Accessing a variable that is declared but not initialized

  2. Accessing a storage that is already disposed at the request of the processor

  3. Accessing a storage that is already disposed at the request of the user

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

All of the above

Multiple choice
  1. go_cart

  2. go4it

  3. 4season

  4. run4

  5. what

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In C, variable names must start with a letter or underscore, not a digit. '4season' begins with 4, making it invalid. 'go_cart', 'go4it', 'run4', and 'what' are all valid as they start with letters and contain only alphanumeric characters/underscores.

Multiple choice
  1. Standard C defines this particular behavior as implementation-dependent. The compiler writer has the freedom to decide how the remaining elements will be handled.

  2. The remaining elements are initialized to zero(0).

  3. It is illegal to initialize only a portion of the array. Either the entire array must be initialized, or no part of it may be initialized.

  4. As with an enum, the compiler assigns values to the remaining elements by counting up from the last explicitly initialized element. The final four elements will acquire the values 4, 5, 6, and 7, respectively.

  5. They are left in an uninitialized state; their values cannot be relied upon.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In C, when an array is partially initialized, all remaining elements are automatically initialized to zero. The compiler fills the uninitialized elements (a[4] through a[7]) with zeros. This is guaranteed by the C standard and not implementation-dependent.

Multiple choice
  1. They are always 32-bit values.

  2. For efficiency, pointer values are always stored in machine registers.

  3. With the exception of generic pointers, similarly typed pointers may be subtracted from each other.

  4. A pointer to one type may not be cast to a pointer to any other type.

  5. With the exception of generic pointers, similarly typed pointers may be added to each other.

Reveal answer Fill a bubble to check yourself
E Correct answer
Multiple choice
  1. if (x == 0) return 0;

  2. return 1;

  3. if (x >= 2) return 2;

  4. if (x == 0) return 1;

  5. if (x <= 1) return 1;

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

A factorial function needs a base case to terminate recursion. For factorial, 0! = 1 and 1! = 1. Option E handles this correctly: when x <= 1, return 1. Otherwise, it recursively computes x * factorial(x-1). Options A and D are incomplete (they don't handle x=1). Option B would cause infinite recursion for x > 1. Option C would return incorrect values.