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 general knowledge science & technology
  1. static variables

  2. register variables

  3. global variables

  4. auto variables

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

External variables are defined outside all functions and have global scope, making them accessible throughout the program. They are commonly called global variables because any function can access them. Static variables have internal linkage, register variables suggest CPU register storage, and auto variables are local function variables - none of these describe external variables.

Multiple choice general knowledge science & technology
  1. 0

  2. -1

  3. 1

  4. void

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

EOF is a macro constant defined as -1 in C/C++ to signal end-of-file or read errors. Functions like getchar() return EOF when they can't read more data. Zero typically indicates success, positive values are valid character codes, and void is a type not a value.

Multiple choice general knowledge science & technology
  1. -1

  2. 1

  3. 0

  4. None

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

In C++, returning 0 from the main() function signals successful program completion to the operating system. Non-zero values typically indicate errors (with specific values sometimes used to distinguish error types). This convention exists in many programming languages and operating systems, where 0 means "no error" and other values indicate failure conditions.

Multiple choice general knowledge science & technology
  1. The program has a syntax error because the required break statement is missing in the switch statement

  2. The program has a syntax error because the required default case is missing in the switch statement

  3. The switch control variable cannot be double

  4. No errors

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

Java's switch statement only works with integral types (int, byte, short, char), String, or enum - not floating-point types like double or float. Using a double as the switch expression is a compilation error.

Multiple choice general knowledge science & technology
  1. if

  2. then

  3. else

  4. for

  5. while

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

In Java, 'if', 'else', 'for', and 'while' are reserved keywords used for control flow statements. The word 'then' is NOT a keyword in Java - Java uses if-else statements without requiring 'then' (unlike some other languages). The 'then' keyword is used in languages like Pascal or Visual Basic but not in Java syntax.

Multiple choice general knowledge
  1. Re-using a stable and standard source code from an existing program

  2. Writing a totally new program from scratch following AXA standards

  3. Using the AXA template to write the program

  4. All of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Multiple choice general knowledge science & technology
  1. include the function's prototype.

  2. include the proper header file.

  3. include the function's definition.

  4. specify the length of the library function.

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

When using built-in functions in C/C++, you must include the proper header file that contains the function's prototype. Header files like , , or declare the functions so the compiler can validate their usage. The function's actual definition is in the library, which is linked during compilation. You don't need to redefine the function or specify its length.

Multiple choice general knowledge science & technology
  1. <ctype.h>

  2. <math.h>

  3. <time.h>

  4. <stdlib.h>

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

The library function isalpha() requires the header file . This header file contains function prototypes for character testing functions like isalpha(), isdigit(), isalnum(), etc. The header is for mathematical functions, for time-related functions, and for general utility functions.

Multiple choice general knowledge science & technology
  1. a variable used to hold a number from the computer's internal clock.

  2. a data type

  3. a built-in library function which will return a value from the internal clock.

  4. a header file.

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

time_t is a data type (typically a typedef for a long integer) used to store time values. It's not a variable, function, or header file. The time() function returns a value of type time_t.

Multiple choice general knowledge science & technology
  1. Subroutine

  2. Compile

  3. Null pointer

  4. Interleave

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

The question asks which term is NOT related to programming. 'Subroutine', 'Compile', and 'Null pointer' are all fundamental programming concepts. 'Interleave' is primarily a term from electronics (interleaving memory) or mathematics (interleaving sequences), not a core programming concept. While interleaving can be used in some programming contexts (like data organization), it's not fundamentally a programming term like the others.

Multiple choice general knowledge science & technology
  1. append(*p,cry,cop);

  2. append(&p,cry,cop);

  3. append(**p,cry,cop);

  4. append(p,cry,cop);

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

The append function takes a double pointer (struct vg **q) to modify the head pointer. When calling from main with p (a single pointer), we must pass &p to match the double pointer parameter. Option B does this correctly.