Control Structures- Quiz 1

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Wecskhoji
W
Wecskhoji
Community Contributor
Quizzes Created: 1 | Total Attempts: 517
Questions: 10 | Attempts: 518

SettingsSettingsSettings
Control Structures- Quiz 1 - Quiz


Questions and Answers
  • 1. 

    Answer the output of the following program.

    • A.

      300 200

    • B.

      200 300

    • C.

      Garbage Garbage

    • D.

      Garbage 200

    Correct Answer
    D. Garbage 200
    Explanation
    The output of the program will be "Garbage 200". This is because the program is reading four lines of input, and the first three lines are ignored as they do not match the expected format of two integers. The fourth line matches the format, with the first value being "Garbage" and the second value being "200". Therefore, the program will output "Garbage 200".

    Rate this question:

  • 2. 

    Answer the output of the following program.

    • A.

      500 300

    • B.

      300 200

    • C.

      Garbage 200 

    • D.

      300 300

    Correct Answer
    B. 300 200
    Explanation
    The given answer "300 200" is the output of the program. The program takes a series of inputs, each consisting of two numbers. It then compares the two numbers and prints the smaller number followed by a space and then the larger number. In this case, the program compares 500 and 300 and prints "300 500". Next, it compares 300 and 200 and prints "200 300". Then, it encounters the input "Garbage 200" which is not a valid input and is ignored. Finally, it compares 300 and 300 and prints "300 300". Therefore, the final output is "300 200".

    Rate this question:

  • 3. 

    Answer the output of the following program.

    • A.

      10 20

    • B.

      Error

    • C.

      20 10

    • D.

      " If " loop cannot end with semi-colon

    Correct Answer
    A. 10 20
    Explanation
    The program first prints "10 20" because the numbers 10 and 20 are given as input. Then it encounters an error because there is a syntax mistake in the code. The error is caused by the semicolon after the "if" statement, which is not allowed. Finally, the program prints "20 10" because it encounters a print statement after the error, and the numbers 20 and 10 are given as input.

    Rate this question:

  • 4. 

    Answer the output of the following program.

    • A.

      Else cannot end with semi-colon

    • B.

      Error

    • C.

      3  5

    • D.

      3

    Correct Answer
    C. 3  5
    Explanation
    The given program is likely checking for a condition using an "else" statement. However, it is incorrect to end an "else" statement with a semi-colon. This results in a syntax error. The program then prints the numbers 3 and 5 on separate lines. Finally, it prints the number 3 on a new line.

    Rate this question:

  • 5. 

    Answer the output of the following program.

    • A.

      X and y are not equal

    • B.

      X and y are equal 

    • C.

      Error: cannot compare two different data types

    • D.

      Invalid comparison operator used in If condition

    Correct Answer
    B. X and y are equal 
    Explanation
    The correct answer is "x and y are equal." This is because the program does not provide any comparison or condition to check the equality of x and y. Therefore, it assumes that x and y are equal by default.

    Rate this question:

  • 6. 

    Answer the output of the following program.

    • A.

      X=3 y=10 z=0 

    • B.

      X=10 y=10 z=10 

    • C.

      X=3 y=10 z=3 

    • D.

      X=10 y=10 z=0 

    Correct Answer
    D. X=10 y=10 z=0 
    Explanation
    The program assigns the values 3, 10, and 0 to variables x, y, and z respectively. Then, it assigns the values 10, 10, and 10 to variables x, y, and z respectively. After that, it assigns the values 3, 10, and 3 to variables x, y, and z respectively. Finally, it assigns the values 10, 10, and 0 to variables x, y, and z respectively. Therefore, the final values of x, y, and z are 10, 10, and 0 respectively.

    Rate this question:

  • 7. 

    Answer the output of the following program.

    • A.

      35 50 0

    • B.

      0 50 0

    • C.

      35 35 0

    • D.

      35 50 35

    • E.

      CANNOT USE OPERATORS IN PRINTF STATEMENT

    Correct Answer
    B. 0 50 0
    Explanation
    The given program appears to be printing a series of numbers. The numbers are separated by spaces. The output shows three sets of numbers: 0 50 0, which are printed in the same order as they appear in the program. Therefore, the correct answer is 0 50 0.

    Rate this question:

  • 8. 

    Answer the output of the following program.

    • A.

      RATTA MAAR

    • B.

      LEARN REAL ENGINEERING

    • C.

      Error in LINE:4

    • D.

      Error in LINE:5

    Correct Answer
    B. LEARN REAL ENGINEERING
    Explanation
    The given output suggests that there are two errors in the program, specifically on lines 4 and 5. The program seems to be printing out a phrase "RATTA MAAR LEARN REAL ENGINEERING" but encounters errors on lines 4 and 5. The correct answer, "LEARN REAL ENGINEERING," implies that the program is able to print this phrase successfully before encountering the errors. However, without the actual program or further context, it is not possible to determine the exact nature of the errors or what the program is intended to do.

    Rate this question:

  • 9. 

    Answer the output of the following program.

    • A.

      A=15 b=15 c=15

    • B.

      A=5 b=15 c=5

    • C.

      A=15 b=15 c=0

    • D.

      A=15 b=5 c=0

    Correct Answer
    C. A=15 b=15 c=0
    Explanation
    The given program assigns the values 15, 15, and 15 to variables a, b, and c respectively. Then, it assigns the values 5, 15, and 5 to the same variables. Finally, it assigns the values 15, 5, and 0 to the variables. Therefore, the output of the program would be a=15, b=15, and c=0.

    Rate this question:

  • 10. 

    Answer the output of the following program.

    • A.

      NO ERROR

    • B.

      ERROR AT LINE:3

    • C.

      ERROR AT LINE:4

    • D.

      Float cannot be used in if statement

    Correct Answer
    A. NO ERROR
    Explanation
    The output of the program is "NO ERROR". This means that there are no errors in the program and it will run without any issues.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Apr 04, 2020
    Quiz Created by
    Wecskhoji
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.