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
Step 1
1 of 2

(A)

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

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

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

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

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

The output for (A):

0

100

(B)

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

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

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

$\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.