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
  1. Common Object

  2. Common

  3. Common Operating

  4. Computer Oriented

  5. None of these

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Single error

  2. Arithmetic error

  3. Control logic error

  4. Comparison error

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. The ELSE clause will be executed.

  2. Control will be passed to the statement following this one.

  3. The value of A will be doubled.

  4. An error will occur and program execution stop.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. The statement Stop program will be displayed

  2. The THEN part of the statement will not be executed

  3. An error message will result

  4. The number 8 will be assigned to the variable X

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. The first executable statement after this statement is executed.

  2.  Answer is correct. is printed.

  3. The program stops executing.

  4. An error message is displayed.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. NEW WORLD RECORD!

  2. GOOD RACE

  3. AVERAGE RACE

  4. Nothing is output

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. NEW WORLD RECORD!

  2. GOOD RACE

  3. AVERAGE RACE

  4. Nothing is output

Reveal answer Fill a bubble to check yourself
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'.

Multiple choice
  1. The message Try out for football team. is displayed.

  2. Nothing happens; program execution simply continues on to the next statement.

  3. An error message is displayed.

  4. The program immediately stops executing.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. IF (Sex$ = "M") AND (Height > 66) AND (Weight >180) THEN PRINT "Try out for football team." END IF
  2. IF (Sex$ = "M") OR (Height > 66) OR (Weight > 180) THEN PRINT "Try out for football team." END IF
  3. IF (Sex$ = "M") AND (Height > 66) OR (Weight > 180) THEN PRINT "Try out for football team." END IF
  4. IF (Sex$ = "M") AND NOT (Height > 66) AND (Weight > 180) THEN PRINT "Try out for football team." END IF
Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. SELECT CASE

  2. single-alternative block IF

  3. double-alternative block IF

  4. END

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Inquiry-and-response

  2. Print

  3. Control

  4. Flowcharting

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. END

  2. END BLOCK

  3. ELSEIF

  4. END IF

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. An error message is displayed.

  2. The program will execute the statement immediately before the block IF statement.

  3. The block IF statement is executed again.

  4. The first statement following the non-executable statement is executed.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Both THEN and ELSE clauses may be executed

  2. ELSE clause is always executed

  3. Either THEN or ELSE clause will be executed

  4. THEN clause is always executed

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. The variables are compared character by character until one of the values is different.

  2. The variables are ignored.

  3. An error will occur.

  4. The second variable is automatically changed to the data type of the first variable.

Reveal answer Fill a bubble to check yourself
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.