Lab 3 Problems Solution

$30.00 $24.00

This lab contains three questions. Q1. Predict the outputs of the following program.(Before running it). Then run the code and check if your answers are correct. “`c++ #include <iostream> using namespace std; int main() { if (12 == 11 || 8 == 8) cout << “condition is true” << endl; else cout << “condition is…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

This lab contains three questions.

Q1. Predict the outputs of the following program.(Before running it). Then run the code and check if your answers are correct.

“`c++

#include <iostream>

using namespace std;

int main() {

if (12 == 11 || 8 == 8)

cout << “condition is true” << endl;

else

cout << “condition is false” << endl;

if (!false && true)

cout << “aaa” << endl;

if (9 < 12)

cout << “bbb” << endl;

else if (9 > 12)

cout << “ccc” << endl;

else

cout << “ddd” << endl;

if (9 > 12) {

if (9 < 17)

cout << “eee” << endl;

}

else

cout << “fff” << endl;

}

“`

Q2. Write a program to do the following:

– ask the user to enter his/her salary.

– if the salary is less than 5, print “I do not believe you.” and exit the program.

– if the salary is between 1000 and 2000, print “We are almost the same.”

– if the salary is even number, print “That is an even salary.”

Bonus. Write a program to do the following:

– ask the user “Can you guess my age? You have 3 chances.”(you may hardcode an age of your choice into your program).

– if the user guesses correctly, print “Congratulations!” and exit the program.

– if the user runs out of guesses, print “You failed.

Lab 3 Problems Solution
$30.00 $24.00