Question

1) What do you think the following program will print if you type from the keyboard...

1) What do you think the following program will print if you type from the keyboard the numbers 3 for a and 8 for b ? #include < iostream> using namespace std; int main() { int a, b; cin >> a >> b; if (a > b && b > 7) { if(a < 7) cout << “ a less than 7: “ << a << ‘\n’; else cout << “Else branch executed\n”; return 0; }

Homework Answers

Answer #1
Given code is
#include <iostream>
using namespace std; 
int main() { 
    int a, b; 
    cin >> a >> b; 
    if (a > b && b > 7) { 
        if(a < 7) 
            cout << " a less than 7: " << a << '\n'; 
        else 
            cout << "Else branch executed\n"; 
    }
    return 0; 
}
So, when a is 3 and b is 8
a > b && b > 7
= 3 > 8 && 8 > 7
= false && 8 > 7
= false

So, code does not prints anything

No output
code does not prints anything
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
11. 4.21 (What Does this Program Do?) What does the following program print? 1 // Exercise...
11. 4.21 (What Does this Program Do?) What does the following program print? 1 // Exercise 4.21: Mystery2.cpp 2 #include <iostream> 3 using namespace std; 4 5 int main() { 6 unsigned int count{1}; 7 8 while (count <= 10) { 9 cout << (count % 2 == 1 ? "****" : "++++++++") << endl; 10 ++count; 11 } 12 }
Analyze the following programs and write down the output of the program. Please print every character...
Analyze the following programs and write down the output of the program. Please print every character (including whitespace character) clearly!       # include <iostream> using namespace std;   int fun( int a ) {       int b = a * 2;       return b;   }   int main()   {       int y = 5;       cout << fun(y) << endl;       cout << fun(-- y) << endl;       cout << fun(y--) << endl;       cout << y <<endl;           return 0;   }
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC...
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC ++++++++++++++ +++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++ Note: The letter C in the output must be uppercase. #include <iostream> using namespace std; int main() {   cout<<"CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC +++++++++++++\n";   cout<<"+++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++";   return 0; } this is my woek #include <iostream> using namespace std; int main() { cout<<"CCCCCCCCC ++...
How to trace a c++ program by hand #include<iostream> using namespace std;    class Test {...
How to trace a c++ program by hand #include<iostream> using namespace std;    class Test {     int value; public:     Test(int v); };    Test::Test(int v) {     value = v; }    int main() {     Test t[100];     return 0; } _______________ #include <iostream> using namespace std; int main() { int i,j; for (i=1; i<=3; i++) { for(j=1; j<=i; j++ ) { cout<<"*"; } cout << "\n";   } return 0; }
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath>...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath> using namespace std; void divisors(int num); int main () {    char repeat;    int num;       while (repeat !='n')    {        cout << "Enter a number: ";        cin >> num;        divisors(num);        cout << "Continue? (y or n): ";        cin >> repeat;    }    return 0; } void divisors(int num) {   ...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std;...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std; int fib(int n) { int temp; if (n <= 0)    return 0; else if (n <= 2)    return 1; else {    temp = fib(n – 1);    return temp + fib(n-2); } } int main() {    int num;    cout << "Which fibonacci number? ";    cin >> num;    cout << fib(num) << endl;    return 0; } You...
Consider the following program: #include #include #include using namespace std; int main() { int num1; int...
Consider the following program: #include #include #include using namespace std; int main() { int num1; int num2; cout << fixed << showpoint << setprecision(2); cout << "Enter two integers: "; cin >> num1 >> num2; cout << endl; if (num1 != 0 && num2 != 0) cout << sqrt(abs(num1 + num2) + 0.5) << endl; else if (num1 != 0) cout << floor(num1 + 0.5) << endl; else if (num2 != 0) cout << ceil(num2 + 0.5) << endl; else...
Write a C++ program to run a menu-driven program with the following choices: Compute the factorial...
Write a C++ program to run a menu-driven program with the following choices: Compute the factorial of a number Compute the alternating factorial of a number Quit #include <iostream> using namespace std; void getValidUserInputPosNumGT0 (int *a) { int num; cout << "Enter in a positive number greater than 0... "; cin >> *a; } long double factorial (int num) { int fact = 1; while (num > 1) { fact *= num; num--; } return fact; } long double AlternatingFactorial...
Write a program which inputs an integer value, incr, from the user at the keyboard, and...
Write a program which inputs an integer value, incr, from the user at the keyboard, and then displays a graph of the sine of the degree values from 0 to 180, in increments of incr. You must use the sin function (in a similar manner to ceil and floor) to find the sine. Note that the sin function only operates on radians so the degree value must first be converted to radians. To do so, multiply the degree value by...
Please write variables and program plan (pseudocode) of the C++ programming code below: #include <iostream> #include...
Please write variables and program plan (pseudocode) of the C++ programming code below: #include <iostream> #include <cmath> using namespace std; int getWeight(); float deliveryCharge(int weight); void displayCharge(int weight); int main () {    displayCharge(getWeight());    return 0; }   int getWeight() {    int weight;    cout << "Enter package weight (oz): ";    cin >> weight;    return weight; } float deliveryCharge(int weight) {    if (weight > 16)    {        return (((weight - 16) / 4) *...