Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

length = 25; width = 60; if ( length = 50 ) height = 4; else height = 8; cout <<

ID: 3551402 • Letter: L

Question

length = 25;

width = 60;

if ( length = 50 )

     height = 4;

else

     height = 8;

cout << length << " " << width << " " << height << endl;

            The programmer expected this to be displayed: 25 60 8

            What was actually displayed: 50 60 4

Correct any problem(s) (Remember: Correct means that correct C++ statements must be used.)











using namespace std;

int main()

{

     int x = 32, y = 26;

     double w, t;

     x = x + y / 4;

     w = 17 / 3 + 6.5;

     t = x / 4.0 + y % 4 - 3.5;

     cout << "x = " << x << " w = " << w
           << " t = " << t << endl;

          return 0;

}








cout << y << endl;


          int i = 3;

          f = i;

Explanation / Answer

1.


length = 25;

width = 60;

if ( length == 50 )

height = 4;

else

height = 8;

cout << length << " " << width << " " << height << endl;


2.


switch(ch){

case 'a':

case 'A': countA+=1;

break;

case 'e':

case 'E': countE += 1;

break;

case 'i':

case 'I': countI += 1;

break;

default: cout << "Error" << endl;

break;

}


3.


x = 38 w = 11.5 t = 8


5.


a. 12 12

b. z = 2


6.


Output is 0.

Static variables (file scope and function static) are initialized to zero.


8.


It is an example of type conversion. Int i is converted to float and stored in f;


9.


cin.get() doesn't get the ' ' typed by user.


10.


a =3 b =15 c =15


11.


it should be

if(t>=35 && t<=67)


otherwise it will accept values even greater than 67