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. x is a 4-digit integer

  2. x cannot be greater than a 4 digit integer

  3. x is a 4-bit integer

  4. none of above

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

In C, the colon syntax in a struct declaration defines a bit-field. The integer x : 4 specifies that x will occupy exactly 4 bits of storage.

Multiple choice
  1. int < unsigned < float < double

  2. unsigned < int < float < double

  3. int< unsigned < double < float

  4. unsigned < int < double < float

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

The standard C implicit type conversion hierarchy (integer promotion and usual arithmetic conversions) is: int < unsigned < float < double.

Multiple choice
  1. Two

  2. One

  3. Infinite

  4. None

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

In C++, destructors are special member functions used to clean up objects. They are defined without parameters and cannot be overloaded, meaning they always take zero arguments.

Multiple choice
  1. integer values

  2. address of another variable

  3. its own address

  4. none of the above

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

A pointer is a variable that holds the memory address of another variable, rather than holding a direct data value like an integer or float.

Multiple choice
  1. int sum(int x,int y,int z) {}

  2. float sum(int x,int y) {}

  3. int sum(int a,int b) {}

  4. all of the above

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

Function overloading occurs when multiple functions have the same name but different parameter lists (different number or types of arguments). Option A changes the number of arguments, which is a valid overload.

Multiple choice
  1. Const

  2. Main

  3. Sizeof

  4. Void

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

In C, 'main' is the name of the function where program execution begins; it is an identifier, not a reserved keyword.

Multiple choice
  1. Constant

  2. Variable

  3. Identifier

  4. Keyword

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

In C, an object is a region of data storage in the execution environment, the contents of which can represent values. Variables are the most common examples of objects.