1) What is the output of each one. You must show your work a) cout << (3*2+6/2-4
ID: 3628668 • Letter: 1
Question
1) What is the output of each one. You must show your worka) cout << (3*2+6/2-4+6*2);
b) cout << (2*7%3);
c) cout <<(2*(7%3));
2) What is the output. You must show your work step by step
int a,b,c,d;
a=1;
b=2;
c=8;
d=4;
c+=a+(b-(c+d)/(d-a+1));
cout << c;
c/=a+b-c+d/d-a+1;
cout << c;
3) What is the output
double w,x,y,z;
int a=9, b=4,c;
w=(double)a + a/b;
cout << w;
x=(double)(a/b);
cout <<x;
y=(double)a/b;
cout << y;
z=double(a)/double(b);
cout << z;
c=double(a)/b;
cout << c;
4) What is the output. Show your work
int y,x=2,b=3,z=4;
y=--b+x++ +3;
cout <<y<<x<<b<<endl;
x=0;
y-=x++ +3;
cout <<y<<x<<endl;
b=0;
z*=b++-y-- /4;
cout <<z<<y<<b<<endl;
5) What is the output. Show your work.
int a=5, b=2;
if (5==a || a < b && b!=2)
cout << "yes";
else
cout << "no ";
6) What is the output. Show your work
char answer=’y’;
if ((answer !='Y' || answer !='y') && (answer !='N' ||answer!='n'))
cout << "invalid";
else
cout << "valid"
8) what does this program output
int max=1;
int i=0,j=1,sum=0;
while (--i < max)
{
i++;
j*=i+2;
sum+=j;
if (i==2)
continue;
if (i==3)
break;
i++;
cout << i << endl;
}
cout << i++ << " "<< sum<<endl
9) write the equivalent while and do-while loops
for (int i=1; i<6; i+=2)
cout << i;
10) write equivalent switch statement
if (x>90 && x <93)
cout << "good";
else if (x==80)
cout << "okay";
else if (x==70)
cout << "bad";
else
cout << "whatever";
11) what is wrong with the following code
a) FLOAT number;
b) cout <<a,b,c;
c) cin >> a,b,c;
d) if (a>b);
cout << "hello"
cout << "good"
else
cout << "bad";
e) for (i=1, i<11, i++);
cout << ‘hello’;
f) int a,
a=a+5;
cout << "what is the value of a";
g) if (a=b)
cout << "true";
12) Write the equivalent boolean expression
int status;
status=0;
if (status==0)
cout << “false”;
else
cout << “true”;
Explanation / Answer
please rate - thanks
some of these answers are dependent on other answers
1) What is the output of each one. You must show your work
a) cout << (3*2+6/2-4+6*2);
6+3-4+12
9-4+12
5+12
17
b) cout << (2*7%3);
14%3
2
c) cout <<(2*(7%3));
2*1
2
2) What is the output. You must show your work step by step
int a,b,c,d;
a=1;
b=2;
c=8;
d=4;
c+=a+(b-(c+d)/(d-a+1));
c=c+a+(b-(c+d)/(d-a+1));
c=8+1+(2-(8+4)/(4-1+1));
9+(2-12/4)
9+2-3
8
cout << c;
8
c/=a+b-c+d/d-a+1;
c=c/(a+b-c+d/d-a+1);
c=8/(1+2-8+4/4-1+1);
8/(-5+1-1+1)
8/-4
-2
cout << c;
-2
3) What is the output
double w,x,y,z;
int a=9, b=4,c;
w=(double)a + a/b;
9.0+9/4
9.0+2
11.0
cout << w;
11.0
x=(double)(a/b);
9/4
2.0
cout <<x;
2.0
y=(double)a/b;
cout << y;
z=double(a)/double(b);
9.0/4.0
2.25
cout << z;
2.25
c=double(a)/b;
9.0/4
2.25
cout << c;
2
4) What is the output. Show your work
int y,x=2,b=3,z=4;
y=--b+x++ +3;
2+2+3
7
cout <<y<<x<<b<<endl;
7 3 2
x=0;
y-=x++ +3;
7- 0+3
cout <<y<<x<<endl;
10 1
b=0;
z*=b++-y-- /4;
4*(0-10/4)
4*-2
-8
cout <<z<<y<<b<<endl;
-8 9 1
5) What is the output. Show your work.
int a=5, b=2;
if (5==a || a < b && b!=2) and has a higher priority, it's done first
5==5 || 5<2&&2!=2
cout << "yes";
else
cout << "no ";
6) What is the output. Show your work
char answer=’y’;
if ((answer !='Y' || answer !='y') && (answer !='N' ||answer!='n'))
if ((y !='Y' || y !='y') && (y !='N' ||y!='n'))
if ((t|| f) && (t ||t))
if ((t) && (t))
t
cout << "invalid";
else
cout << "valid"
8) what does this program output
int max=1;
int i=0,j=1,sum=0;
while (--i < max) -1<1 1<1 no
{
i++; i= 0
j*=i+2; j= 2
sum+=j; sum= 2
if (i==2) no
continue;
if (i==3) no
break;
i++; i=1
cout << i << endl; 1
}
cout << i++ << " "<< sum<<endl
output is
1
1 2
9) write the equivalent while and do-while loops
for (int i=1; i<6; i+=2)
cout << i;
int i=1;
do
{cout<<i;
i+=2;
}while(i<6);
----------
int i=1;
while(i<6)
{cout<<i;
i+=2;
}
10) write equivalent switch statement
if (x>90 && x <93)
cout << "good";
else if (x==80)
cout << "okay";
else if (x==70)
cout << "bad";
else
cout << "whatever";
switch(x)
{case 91:
case 92: cout<<"good"
break;
case 80: cout<<"okay";
break;
case 70: cout<<"bad";
break;
default: cout<<"whatever";
break;
}
11) what is wrong with the following code
a) FLOAT number; should be float number; not uppercase
b) cout <<a,b,c; should be cout<<a<<b<<c; << not ,
c) cin >> a,b,c; should be cin>>a>>b>>c; >> not ,
d) if (a>b);
cout << "hello"
cout << "good"
else
cout << "bad";
should be
if (a>b) // no;
{cout << "hello" // {}missing
cout << "good"
}
else
cout << "bad";
e) for (i=1, i<11, i++);
cout << ‘hello’; should be cout<<"hello";
f) int a,
a=a+5;
cout << "what is the value of a";
wrong order plus other things
should be
int a;
cout << "what is the value of a";
cin>>a;
a=a+5;
g) if (a=b) should be if(a==b)
cout << "true";
12) Write the equivalent boolean expression
int status;
status=0;
if (status==0)
cout << “false”;
else
cout << “true”;
should be
bool status;
status=false;
cout<<status;
or
bool status
status=false;
if(status)
cout<<"true";
else
cout<<false;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.