Computer Knowledge

Programming Fundamentals

2,611 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. Function declaration is correct.

  2. Parameter cannot be given default value in function declaration.

  3. All parameters that take default value, must appear to right of those that do not.

  4. Default argument of parameter cannot be zero.

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

This option is correct as the only problem with the above function declaration is that a is intialized, but b is not. However, if a is intialized then b should also be initialized as explained in above option.

Multiple choice
  1. Inline

  2. Continue

  3. Return

  4. Overload

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

Overload keyword is now obsolete and is no longer used or supported. It is not a part of Standard C++. It was preceded with function name in its definition to indicate that it was an overloaded function. Hence, this is the correct answer.

Multiple choice
  1. calls itself

  2. is equivalent to the loop

  3. has termination condition

  4. does not return a value

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

Recursive functions are capable of returning values, such as the result of a factorial or Fibonacci calculation. The other statements are true: they call themselves, require a termination condition to avoid infinite loops, and can be logically replaced by iterative loops.

Multiple choice
  1. int

  2. char

  3. float

  4. none of these

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

The switch statement in C requires the controlling expression to be of an integral type, such as int, char, or an enumeration. Floating-point values are not allowed because they cannot be reliably checked for exact equality due to precision issues.

Multiple choice
  1. 1-a, 2-b, 3-c, 4-d

  2. 1-a, 2-d, 3-b, 4-c

  3. 1-a, 2-c, 3-b, 4-d

  4. None of these

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

Local variables are stored on the stack, while global and static variables are stored in the data segment of main memory. Register variables are stored in CPU registers for faster access, matching the pairs 1-a, 2-d, 3-b, and 4-c.

Multiple choice
  1. II

  2. I, II

  3. II, III

  4. None of these

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

Command line arguments are always passed to the main function as an array of strings, even if they represent numeric values. Statement I is false because arguments are runtime inputs, and statement III is false because the first argument is the program name.