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. Yes; it can be referenced through the register specifier.

  2. No; it would need to have been initially declared as a static variable.

  3. No; it would need to have been initially declared using the global keyword.

  4. Yes; it can be referenced through the publish specifier.

  5. Yes; it can be referenced through the extern specifier.

Reveal answer Fill a bubble to check yourself
C Correct answer
Multiple choice
  1. If the arguments to memcpy() refer to overlapping regions, the destination buffer will be subject to memory corruption.

  2. Array_dup() declares its first parameter to be a pointer, when the actual argument will be an array.

  3. The memory obtained from alloca() is not valid in the context of the caller. Moreover, alloca() is non-standard.

  4. Size_t is not a standard C defined type, and may not be kn.

  5. The definition of array_dup() is unusual. Functions cannot be defined using this syntax.

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

Option (1) is correct.

Multiple choice
  1. Int sprintf ( char * str, const char * format)

  2. Void sprintf ( char * str, const char * format, ...)

  3. Int sprintf ( int, const char * format, ... )

  4. Int sprintf ( char * str, const char * format, ... )

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

This is the correct answer as it returns integer which represents the number of characters successfully written on string (first argument). Also the three dots at the end represents that it can have variable number of arguments which is required.

Multiple choice
  1. Inline functions

  2. Constructors

  3. Destructors

  4. None of the above

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

Inline functions are very useful when we need to create efficient code as their code is expanded each time they are invoked. Inline functions are preceded by inline keyword. For example: inline int findlarge(int x, int y) {return x > y ? x : y;}. Hence, this is the correct answer.