Learn with Yasir

Share Your Feedback

C++ Conditional Structures: Output Practice Questions


Practice C++ output basics with beginner-friendly questions on cout, variables, arithmetic expressions, and predicting console output in simple programs.

Instructions for Students

  1. Read the program carefully.
  2. Predict the output without running the code.
  3. Write your predicted output.
  4. Run the program to verify your answer.
  5. Understand why the output appears.
  6. Modify the code and predict the new output.

Question 1:

Task: Predict the output.

Code

int x = 10;

if (x > 5)
    cout << "Yes";

Question 2:

Task: Predict the output.

Code

int x = 3;

if (x > 5)
    cout << "A";

cout << "B";

Question 3:

Task: Predict the output.

Code

int n = 8;

if (n % 2 == 0)
    cout << "Even";
else
    cout << "Odd";


Question 4:

Task: Predict the output.

Code

int x = 12;

if (x >= 12)
    cout << "Pass";
else
    cout << "Fail";

Question 5:

Task: Predict the output.

Code

int x = 5;

if (x != 5)
    cout << "A";
else
    cout << "B";

cout << "C";

Question 6:

Task: Predict the output.

Code

int x = 10;

if (x > 5)
{
    cout << "A";
    cout << "B";
}
else
{
    cout << "C";
}
cout << "D";

Question 7:

Task: Predict the output.

Code

int marks = 45;

if (marks >= 50)
    cout << "Pass";
else
    cout << "Fail";

cout << "!";