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
-
text editor
-
compiler
-
loader
-
debugger
D
Correct answer
Explanation
A debugger is a tool that allows programmers to detect, identify, and fix runtime errors by monitoring program execution flow.
-
Segment
-
AFTER DROP trigger
-
BEFORE trigger
-
Trigger event
-
Trigger restriction
E
Correct answer
Explanation
This part of the trigger specifies a boolean expression that must be true for the trigger to fire.
A
Correct answer
Explanation
In C and C++, enumerated data types (enums) assign integer values starting from 0 by default. The first enumerator gets value 0, the next gets 1, and so on sequentially. However, programmers can explicitly assign different values if needed. This default behavior makes enums useful for array indexing and creating named constants.
A
Correct answer
Explanation
The arrow operator (->) is used in C/C++ to access members of a structure or class through a pointer. If ptr is a pointer to a structure, ptr->member is equivalent to (*ptr).member. This is a fundamental pointer operation for structured data.
-
stdlib.h
-
process.h
-
stdio.h
-
dos.h
C
Correct answer
Explanation
The fputs function writes a string to a file stream and is declared in stdio.h, which contains standard input/output functions. This header includes file operations like fputs, fgets, fprintf, and fscanf. stdlib.h is for general utilities, process.h for process control, and dos.h for DOS-specific functions.
-
dos.h
-
stdlib.h
-
alloc.h
-
ctype.h
D
Correct answer
Explanation
The isascii function checks if a character is an ASCII character (value 0-127) and is declared in ctype.h. This header contains character classification functions like isalpha, isdigit, islower, and isspace. alloc.h is for memory allocation, stdlib.h for general utilities, and dos.h for DOS-specific functions.
-
virtual
-
assignment
-
pointer
-
object
A
Correct answer
Explanation
In C++, 'virtual' is a reserved keyword used for polymorphism. Reserved keywords cannot be used as variable names, while 'assignment', 'pointer', and 'object' are valid identifiers.
-
applegrapesinvalid choice
-
applegrapesinvalid choicebanana
-
apple
-
none of these
A
Correct answer
Explanation
When input is 'a', case 'a' executes but has no break statement, causing fallthrough to case 'g' and then default. This outputs 'apple' + 'grapes' + 'invalid choice' without spaces.
-
extraction operator
-
insertion operator
-
get from operator
-
put to operator
D
Correct answer
Explanation
The << operator is called the 'put to' or insertion operator in C++ stream operations. It directs data to an output stream. Conversely, >> is the 'get from' or extraction operator.
-
for
-
while
-
do-while
-
all of the above
D
Correct answer
Explanation
The break statement immediately terminates the nearest enclosing loop or switch statement. It works with all loop types - for, while, and do-while - as well as switch statements, transferring control to the statement following the loop/switch.
-
integer
-
char
-
float
-
either int or char
D
Correct answer
Explanation
The switch statement in C requires an expression that evaluates to an integer type. Since characters are stored as integer values (ASCII/Unicode codes), both int and char types are valid. Float is not allowed because it's not an integral type.
-
float process( int i, float a, float b)
-
double process(int i, double a, double b);
-
double process (int i, float a, float b);
-
long process(int i, float a, float b);
C
Correct answer
Explanation
The function signature must match the specification: accepts an integer (int i), two floating point numbers (float a, float b), and returns a double precision quantity (double return type). Option C matches exactly: double process(int i, float a, float b). Note that option B is a declaration (semicolon) not a definition (no body).
-
compare three strings
-
compare two strings
-
copy strings
-
compare and then copy strings
B
Correct answer
Explanation
strcmp is a standard C library function that compares two strings lexicographically (character by character). It returns a negative value if the first string is less than the second, zero if they're equal, and positive if the first is greater. It cannot compare three strings at once, nor does it copy strings.
-
float *(15)[30];
-
float [15][30];
-
float *(x)[30];
-
float *x[30];
C
Correct answer
Explanation
The declaration 'float *(x)[30]' declares x as a pointer to an array of 30 floats. This is the correct syntax for declaring a pointer to a fixed-size 2D array where each row has exactly 30 float elements. The parentheses are crucial - they bind the pointer to the array, not to individual float elements.
-
p is a pointer to integer x
-
both p and x are pointers to integer quantity
-
px is an array of integer pointer
-
px is a pointer to an integer quantity
D
Correct answer
Explanation
The declaration 'int px' means px is a pointer variable that can hold the address of an integer quantity. The asterisk () indicates that px is a pointer, and 'int' specifies that it points to an integer type. Pointer variables store memory addresses, not the actual values.