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
-
static variables
-
register variables
-
global variables
-
auto variables
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.
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.
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.
-
Tiger Graphics
-
Turtle Graphics
-
Mouse Graphics
-
Hi-Res Graphics
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.
-
The program has a syntax error because the required break statement is missing in the switch statement
-
The program has a syntax error because the required default case is missing in the switch statement
-
The switch control variable cannot be double
-
No errors
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.
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.
-
var
-
identifier
-
variable
-
container
A
Correct answer
Explanation
The 'var' keyword is used to declare variables in JavaScript. While modern JavaScript also supports 'let' and 'const' for variable declarations, 'var' was the original keyword and remains in use for legacy compatibility.
-
Developing computer applications using a language that a computer understands
-
Asking a robot to bring water from the water-cooler
-
Teaching your servant how to cook fried rice
-
All the above
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.
-
Re-using a stable and standard source code from an existing program
-
Writing a totally new program from scratch following AXA standards
-
Using the AXA template to write the program
-
All of the above
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.
-
include the function's prototype.
-
include the proper header file.
-
include the function's definition.
-
specify the length of the library function.
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.
-
<ctype.h>
-
<math.h>
-
<time.h>
-
<stdlib.h>
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.
-
<ctype.h>
-
<math.h>
-
<stdlib.h>
-
<time.h>
B
Correct answer
Explanation
The ceil() function rounds a floating-point number up to the nearest integer and is declared in . Don't confuse it with which handles character classification.
-
a variable used to hold a number from the computer's internal clock.
-
a data type
-
a built-in library function which will return a value from the internal clock.
-
a header file.
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.