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 technology programming languages
  1. sin()

  2. kbhit()

  3. tmpnam()

  4. None of the Above

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

kbhit() is a non-standard DOS/Windows function from conio.h that checks if a key has been pressed. sin() is a standard math function, and tmpnam() is a standard C/C++ function for generating temporary filenames. ANSI C++ does not include kbhit().

Multiple choice technology programming languages
  1. No

  2. Case sensitivity is compiler-determined

  3. Yes

  4. None of the Above

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

C++ is case-sensitive, meaning identifiers like 'Main', 'main', and 'MAIN' are treated as completely different symbols. This applies to variable names, function names, keywords, and all other identifiers. The compiler distinguishes strictly by character case.

Multiple choice technology programming languages
  1. Yes

  2. No

  3. Only optimized compilers will compile C++ code.

  4. None of the Above

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

C compilers are designed to compile C code only. C++ includes additional features like classes, templates, and function overloading that C compilers do not understand. C++ code must be compiled with a C++ compiler that supports these language extensions.

Multiple choice technology programming languages
  1. The snippet is illegal

  2. It loops forever

  3. It is ignored by compiler, but it is not illegal

  4. None of the Above

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

The syntax for(;;) ; is a valid C/C++ statement. The empty conditions in the for loop default to true, and the trailing semicolon represents an empty loop body, causing the program to loop infinitely.

Multiple choice technology programming languages
  1. Copies "This" into an_array

  2. Adds "This" to the end of an_array

  3. Compares an_array and "This"

  4. None of the Above

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

To understand what the code strcat(an_array, "This") does, we need to know that strcat() is a function in C language that concatenates (joins) two strings.

The function takes two arguments: the first argument is the destination array (where the concatenated string will be stored), and the second argument is the source string (which will be concatenated to the destination array).

In this case, the function call strcat(an_array, "This") concatenates the string "This" to the end of the string already stored in an_array. Therefore, the correct option is:

The Answer is: B. Adds "This" to the end of an_array

Multiple choice technology programming languages
  1. Breaks out of the if statement

  2. Exits the function

  3. Nothing (Compiler error)

  4. None of the Above

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

The break statement can only be used inside loops (for, while, do-while) or switch statements. Using break inside an if statement that is not contained in a loop or switch is a compilation error. The code attempts to break from just an if block, which is invalid.

Multiple choice technology programming languages
  1. int main()

  2. int main(int argc, char *argv[])

  3. They both work

  4. None of the Above

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

Both 'int main()' and 'int main(int argc, char *argv[])' are valid declarations for main() in C and C++. The first is for programs without command-line arguments, the second for programs that need to process command-line arguments. Both are standard and correct.

Multiple choice technology programming languages
  1. True

  2. False

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

ERROR is NOT an internal SAS variable used to mark errors within a dataset. The correct automatic variable is ERROR (with one underscore on each side), which is set to 1 when an error occurs during DATA step execution. However, the question asks about it being used to mark errors 'within a dataset', which is misleading - it marks DATA step execution errors, not dataset-specific errors.

Multiple choice technology programming languages
  1. Character

  2. Date

  3. Integer

  4. RAW

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

RAW datatype in Informatica represents binary data and cannot be implicitly or explicitly converted to other datatypes like string, number, or date. RAW data must be handled as binary - attempting conversion will cause errors. Character, Date, and Integer can all be converted to each other using appropriate conversion functions like TO_CHAR, TO_DATE, or TO_INTEGER.