Question

What will the following programs print on the screen?

A)

#include <iostream>
using namespace std;
int main()
{
    int freeze = 32, boil = 212;
    freeze = 0;
    boil = 100;
    cout << freeze << endl << boil << endl;
    return 0;
}

B)

#include <iostream>
using namespace std;
int main()
{
    int x = 0, y = 2;
    x = y * 4;
    cout << x << endl << y << endl;
    return 0;
}

C)

#include <iostream>
using namespace std;
int main()
{
    cout << "I am the incredible";
    cout << "computing\nmachine";
    cout << "\nand I will\namaze\n";
    cout << "you.\n";
    return 0;
}

Solutions

Verified
Answered 1 year ago
Step 1
1 of 2

(A)

int\text{\textcolor{#19804f}{int}} freeze= 32, boil = 212;

Here, freeze is assigned value 32 and boil is assigned value 212\text{\textcolor{#c34632}{Here, freeze is assigned value 32 and boil is assigned value 212}}

freeze = 0; value assigned to freeze is updated to 0\text{\textcolor{#c34632}{value assigned to freeze is updated to 0}}

boil = 100 ; value assigned to boil is updated to 100\text{\textcolor{#c34632}{value assigned to boil is updated to 100}}

cout\text{\textcolor{#4257b2}{cout}} <<<<freeze<<<< endl <<<< boil <<<< endl ;

The output for (A):

0

100

(B)

int\text{\textcolor{#19804f}{int}} x=0, y= 2;

Here, x is assigned value 0 and y is assigned value 2\text{\textcolor{#c34632}{Here, x is assigned value 0 and y is assigned value 2}}

x=y×4x= y\times 4; $\text{\textcolor{#c34632}{value assigned to x is updated to y×4=2×4=8y\times 4=2\times 4=8}}$

cout\text{\textcolor{#4257b2}{cout}} <<<<x<<<< endl <<<< y<<<< endl ;

The output for (B):

8

2

(C) Since \\text{\textbackslash} n is newline escape character it jumps to a new line.

The output for (C):

I am the incrediblecomputing

machine

and I will

amaze

you.

Create an account to view solutions

By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Continue with GoogleContinue with Facebook

Create an account to view solutions

By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Continue with GoogleContinue with Facebook

Related questions