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
-
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.
-
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.
-
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
-
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.
-
Subroutine
-
Compile
-
Null pointer
-
Interleave
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.
-
int[ ] anArray
-
int anarray[ ]
-
int [ ]anarray[ ]
-
all the above
D
Correct answer
Explanation
In Java, array declarations can use the bracket notation before the variable name, after it, or both - all three syntaxes (int[] arr, int arr[], int []arr[]) are valid.
-
append(*p,cry,cop);
-
append(&p,cry,cop);
-
append(**p,cry,cop);
-
append(p,cry,cop);
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.
B
Correct answer
Explanation
A dangling pointer is just a pointer holding an invalid address - it's still a pointer variable and can be used in data structures like linked lists, arrays, etc. The statement is false.