Computer Knowledge

Programming Fundamentals

2,381 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. Tiger Graphics

  2. Turtle Graphics

  3. Mouse Graphics

  4. Hi-Res Graphics

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

LOGO is best known for turtle graphics, a feature where students control an on-screen "turtle" that draws as it moves, teaching programming concepts visually. The turtle moves with commands like FORWARD, BACK, LEFT, RIGHT, making abstract programming concepts concrete. This educational approach was revolutionary for teaching programming to children in the 1960s-70s.

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. Developing computer applications using a language that a computer understands

  2. Asking a robot to bring water from the water-cooler

  3. Teaching your servant how to cook fried rice

  4. All the above

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

Programming can be broadly understood as giving instructions to achieve a specific outcome, whether to computers, robots, or even people. All the given examples involve giving structured instructions to perform tasks.

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
  1. C

  2. Java

  3. CPP

  4. .Net

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

This question is poorly framed as 'odd' is ambiguous without criteria. C is a procedural language while Java and C++ are object-oriented, and .NET is a framework. The answer depends on unstated classification rules.

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.