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
- Read the program carefully.
- Predict the output without running the code.
- Write your predicted output.
- Run the program to verify your answer.
- Understand why the output appears.
- 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 << "!";