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. Only a

  2. Both a and b

  3. All a, b and c

  4. Both b and c

  5. None of the above

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

The program code is not simple if it contains loops, decision making statements and recursion. Option 3 is the correct answer.

Multiple choice
  1. Sets the precision

  2. Sets the initial or basic value of variable

  3. Converts the data of one number system to another

  4. No such manipulator present in C++

  5. Sets the base type like decimal, binary, hexadecimal

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

It is conversion manipulator that converts data of one number system to another.e.g.int x=15;cout<.

Multiple choice
  1. Virtual functions<o:p></o:p>

  2. templates<o:p></o:p>

  3. Namespaces<o:p></o:p>

  4. Inline function<o:p></o:p>

  5. None of above

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

Namespaces (user defined) are used for distinctly separating the scopes of the declarations and definitions in a program where the name clashes are likely to occur.

Multiple choice
  1. Only (1)

  2. Only (2)

  3. Only (3)

  4. Both (1) & (2)

  5. Both (2) & (3)

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

Function declaration no doubt specifies return type and parameters of function. So, statement (1) is correct. Variable declared in a function is unique. So, it cannot be used by another function. So, statement (2) is false. Rules of function allow us to declare as many functions in a program as we want. So, statement (3) is incorrect. Hence, only statement (2) is correct.

Multiple choice
  1. We put a semicolon in “while loop” after the while expression as in while(expression); , but semicolon is not allowed after while expression in “do while loop”.

  2. Difference between while loop and do while loop is the place where condition is tested.

  3. ”nested if“ statements cannot be used in while loop, but we can use “nested if” statements in do while loop.

  4. 'do while loop' causes the program to take more time to execute than while loop.

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

We can use nested statements in both while loop and do while loop. So, option (3) is incorrect. While and do while loop take some time to execute the program. So, option (4) is also incorrect. We put a semicolon after while (expression) in do while loop, not in while loop. So, option (1) is also incorrect. In while loop, condition is checked following the while loop, but in do while loop, condition is checked at end of loop. Hence, option (4) is the correct answer.

Multiple choice
  1. Only (1)

  2. Only (2)

  3. Only (3)

  4. Both (1) & (2)

  5. Both (1) & (3)

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

The initialize counter of for loop sets the loop to initial value. For example: for (i =0; i<10; iH), loop initializes to zero. So, statement (1) is correct. The do while loop executes the body of loop at least once regardless of the logical condition. So, statement (2) is incorrect. The body of for loop does not require braces if there is only one statement after for loop. So, statement (3) is incorrect. Hence, option (1) is correct.

Multiple choice
  1. Only (1)

  2. Only (2)

  3. Only (3)

  4. Both (1) & (3)

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

Variable name cannot start with a digit. So, statement (1) is incorrect. Variable cannot be a C keyword. So, statement (2) is incorrect. Spaces cannot be there while declaring variable. So, statement (3) is correct.

Multiple choice
  1. The variable name cannot start with a digit.

  2. The variables cannot be a C keyword.

  3. They must begin with a character without spaces but underscore is not permitted.

  4. Both 1 and 3.

  5. None of these

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

Yes, this is true that variable name must start with a character. But we are allowed to put underscore. For example, Int ab_c; is a valid variable in C. So, this rule is not correct.

Multiple choice
  1. local symbols/ functions

  2. global symbols/functions

  3. library functions only

  4. for execution of the program

  5. none of the above

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

The local symbols/ functions are resolved by the compiler because all references are available to compiler. But global symbols/functions cannot be resolved by the compiler because the references are not available to the compiler. These are resolved after the compilation using linker.