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
-
Common Object
-
Common
-
Common Operating
-
Computer Oriented
-
None of these
B
Correct answer
Explanation
COBOL stands for Common Business-Oriented Language, so CO stands for 'Common'. The name reflects its design for business data processing applications.
-
Single error
-
Arithmetic error
-
Control logic error
-
Comparison error
A
Correct answer
Explanation
Common module errors in programming include arithmetic errors (calculation mistakes), control logic errors (flawed conditionals or loops), and comparison errors (incorrect relational operations). 'Single error' is not a standard category of programming errors - it's not a recognized type of module error.
-
The ELSE clause will be executed.
-
Control will be passed to the statement following this one.
-
The value of A will be doubled.
-
An error will occur and program execution stop.
B
Correct answer
Explanation
When A=30, the condition (A = 32) evaluates to false, so the code inside the IF block is skipped. Control simply passes to the next statement after END IF. No ELSE clause exists, and no error occurs.
-
The statement Stop program will be displayed
-
The THEN part of the statement will not be executed
-
An error message will result
-
The number 8 will be assigned to the variable X
A
Correct answer
Explanation
When X=22, the condition (X <> 8) is true (22 is not equal to 8), so the THEN clause executes and prints 'Stop program'. Option B is incorrect because the THEN clause does execute. No error occurs or value assignment happens.
-
The first executable statement after this statement is executed.
-
Answer is correct. is printed.
-
The program stops executing.
-
An error message is displayed.
B
Correct answer
Explanation
When X=7, the expression (X+3)+5 = (7+3)+5 = 15. Since 15 > 10 is true, the THEN clause executes and prints 'Answer is correct.' The program doesn't stop or error; it simply executes the PRINT statement.
-
NEW WORLD RECORD!
-
GOOD RACE
-
AVERAGE RACE
-
Nothing is output
A
Correct answer
Explanation
When Time=120 and Best=121, the condition (Time < Best) is true (120 < 121), so the first branch executes and prints 'NEW WORLD RECORD!' The ELSEIF and ELSE clauses are never reached.
-
NEW WORLD RECORD!
-
GOOD RACE
-
AVERAGE RACE
-
Nothing is output
C
Correct answer
Explanation
When Time=130 and Best=120: First condition (130 < 120) is false. ELSEIF checks (130 < 120+10) = (130 < 130), which is also false (not strictly less than). Thus the ELSE clause executes, printing 'AVERAGE RACE'.
-
The message Try out for football team. is displayed.
-
Nothing happens; program execution simply continues on to the next statement.
-
An error message is displayed.
-
The program immediately stops executing.
B
Correct answer
Explanation
When Height=66, the condition (Height > 66) is false because 66 is not greater than 66 (it's equal). The innermost IF block containing the PRINT statement is never executed. No error occurs; the nested IFs simply complete without action.
-
IF (Sex$ = "M") AND (Height > 66) AND (Weight >180) THEN
PRINT "Try out for football team."
END IF
-
IF (Sex$ = "M") OR (Height > 66) OR (Weight > 180) THEN
PRINT "Try out for football team."
END IF
-
IF (Sex$ = "M") AND (Height > 66) OR (Weight > 180) THEN
PRINT "Try out for football team."
END IF
-
IF (Sex$ = "M") AND NOT (Height > 66) AND (Weight > 180) THEN
PRINT "Try out for football team."
END IF
A
Correct answer
Explanation
The nested IFs require ALL conditions to be true: Sex$ = "M" AND Height > 66 AND Weight > 180. Only option A correctly uses AND to combine all three conditions.
-
SELECT CASE
-
single-alternative block IF
-
double-alternative block IF
-
END
D
Correct answer
Explanation
SELECT CASE and both single-alternative and double-alternative block IF statements are all control structures that direct program flow. END is a termination keyword used to close blocks, but it doesn't control program flow itself. END simply marks the conclusion of a block structure like IF or SELECT CASE.
-
Inquiry-and-response
-
Print
-
Control
-
Flowcharting
C
Correct answer
Explanation
Control statements like IF, SELECT CASE, and loops allow programmers to alter the sequential execution of a program. Inquiry-and-response handles user input, Print displays output, and Flowcharting is a design tool. Only control statements actively change the flow of program execution by making decisions or repeating actions based on conditions.
-
END
-
END BLOCK
-
ELSEIF
-
END IF
D
Correct answer
Explanation
In block IF structures, the block must be properly terminated. The END IF statement marks the conclusion of the IF block. While END alone terminates other structures like SELECT CASE, the specific syntax for block IF requires END IF to properly close the conditional block and maintain code clarity.
-
An error message is displayed.
-
The program will execute the statement immediately before the block IF statement.
-
The block IF statement is executed again.
-
The first statement following the non-executable statement is executed.
D
Correct answer
Explanation
Non-executable statements like REM (remark/comment) are ignored during program execution. When a non-executable statement appears after a block IF, the program simply skips it and continues to the next executable statement. The block IF has already been evaluated, and execution proceeds to the first executable instruction following the REM statement. No error occurs, and the IF is not re-executed.
-
Both THEN and ELSE clauses may be executed
-
ELSE clause is always executed
-
Either THEN or ELSE clause will be executed
-
THEN clause is always executed
C
Correct answer
Explanation
In a double-alternative block IF, the condition is evaluated once. If true, the THEN clause executes and the ELSE clause is skipped. If false, the ELSE clause executes and the THEN clause is skipped. Only one of the two clauses ever executes during a single pass through the IF statement - never both, and never neither.
-
The variables are compared character by character until one of the values is different.
-
The variables are ignored.
-
An error will occur.
-
The second variable is automatically changed to the data type of the first variable.
C
Correct answer
Explanation
Programming languages enforce type compatibility when comparing variables. You cannot directly compare a string variable (which stores text) to a numeric variable (which stores numbers) because they represent different kinds of data. This type mismatch will generate an error rather than attempting an invalid comparison.