T/F The following code will compile without error. int x = 3, y = 4, z = 5; double k = 3.4; cout << x + y / z – k << endl << ;
T/F The following code will compile without error. int x = 3, y = 4, z = 5; double k = 3.4; cout << x + y / z – k << endl << ; // insertion symbol causes error
What does the following code print? cout << double(4 / 3) – 2 << endl;
What does the following code print? cout << double(4 / 3) – 2 << endl; // // -1
What does the following code print int x = 5; x +=20; x = sqrt(x); x--; cout << x << endl;
What does the following code print int x = 5; x +=20; // 25 x = sqrt(x); // 5 x--; // 4 cout << x << endl; // 4
What does the following code print? int x = 5, y = 13; x *= 5; x ++; x /= 4; y = 100; cout << y << endl;
What does the following code print? int x = 5, y = 13; x *= 5; x ++; x /= 4; y = 100; cout << y << endl; // Prints 100
What does the following code print? int x = 4, y = 5, z = 6; x = (x + y) % z; x++; y++; x += y; cout << x << endl;
What does the following code print? int x = 4, y = 5, z = 6; x = (x + y) % z; //9 mod 6 = 3 x++; // x = 4 y++; // y = 6 x += y; // x = 10 cout << x << endl; // Prints 10
What does the following code print? double x = 1.5, y = 2.5, z = 3; cout << int (z)/int(y) + x << endl;
What does the following code print? double x = 1.5, y = 2.5, z = 3; cout << int (z)/int(y) + x << endl; // // 2.5
What does the following code print? const double MYSTERY = 4.5; int x = 3, y = 4; cout << MYSTERY + 4; const MYSTERY2 = 3; cout << MYSTERY2 + 4;
What does the following code print? const double MYSTERY = 4.5; int x = 3, y = 4; cout << MYSTERY + 4; const MYSTERY2 = 3; // ERROR! cout << MYSTERY2 + 4;
What does the following code print? const int MYSTERY = 4; int y = 1, z = 2; cout << sqrt(MYSTERY) + pow(MYSTERY, z) * 1 << endl;
What does the following code print? const int MYSTERY = 4; int y = 1, z = 2; cout << sqrt(MYSTERY) + pow(MYSTERY, z) * 1 << endl; // * 1 // 18
What does the following code print? double x = 0.5; int y = 20; cout << (y%5) * x << endl;
What does the following code print? double x = 0.5; int y = 20; cout << (y%5) * x << endl; // 0 * 0.5 // 0
int x =1, y = 2, z = 3, p = 4, q = 5; x ++; x+=y; x++; x+=z; x++; x+=p; cout << x << endl;
int x =1, y = 2, z = 3, p = 4, q = 5; x ++; // x = 2 x+=y; // x = 4 x++; // x = 5 x+=z; // x = 8 x++; // x = 9 x+=p; // x = 13 cout << x << endl;
double x = 0.5, y = 1.5; cout << int(x + x + x + x + y) << endl;
double x = 0.5, y = 1.5; cout << int(x + x + x + x + y) << endl; // // 3
int x = 15, y = 2, z = 3; x = x + sqrt(pow(z, y) + 16); cout << x << endl;
int x = 15, y = 2, z = 3; x = x + sqrt(pow(z, y) + 16); // 15 + sqrt(9 + 16) // // 20
int x, y, z; x = 15; z = y = x; cout << “ z = “ << z << endl; cout << “y = “ << y << endl; cout << “x = “ << x << endl;
int x, y = 5, z = 4; x = 15; z = y = x; cout << “ z = “ << z << endl; // z = 15 cout << “y = “ << y << endl; // y = 15 cout << “x = “ << x << endl; // x = 15
const double y = 55.5; y++; cout << y << endl;
const double y = 55.5; y++; // ERROR cout << y << endl;
double y = 5.5; cout << int(y) << endl; cout << y << endl;
double y = 5.5; cout << int(y) << endl; // 5 cout << y << endl; // 5.5
int y = 4, x = 5, z = 7; x = z; cout << “z = “ << z << endl; cout << “x = “ << x << endl;
int y = 4, x = 5, z = 7; x = z; cout << “z = “ << z << endl; // z= 7 cout << “x = “ << x << endl; // x = 7
cout << abs(int(5.9) * -1) << endl;
// abs( 5 * -1) // abs(-5) // 5
cout<< int(5) / double(2) << endl;
// 5 / 2.0 // 2.5
Type the symbol for the assignment operator.
// =
What is the difference between syntax and semantics?
// Syntax – Rules for creating statements // Semantics – How we interpret statements
True or false? bool x = true; int y = 5, z = 6; (y > z && x )
True or false? bool x = true; int y = 5, z = 6; (y > z && x ) // F
True or false? bool x = true, y = false, z = false (x && !y && !z)
True or false? bool x = true, y = false, z = false (x && !y && !z) True!
What does the code print? int x = 4, y = 2, z = 1; if(y ==2) if( z ==1) x += 6; else x =4; else x += 8; cout << x << endl;
What does the code print? int x = 4, y = 2, z = 1; if(y ==2) // True if( z ==1) // True x += 6; // x = 10 else x =4; else x += 8; cout << x << endl;
What does the code print? int x = 54; if(x>= 5 && x <= 100) x = 4; else x = 5; cout << x << endl;
What does the code print? int x = 54; if(x>= 5 && x <= 100) // True x = 4; // x = 4 else x = 5; cout << x << endl; // 4
What does the code print? int x = 14; if(x < 10) cout << “1”; if (x > 10) cout << “2”; if ( x >10 && x < 20) cout << “3”; if(x ==10 || x ==14) cout << “4”;
What does the code print? int x = 14; if(x < 10) // false cout << “1”; if (x > 10) // true cout << “2”; if ( x >10 && x < 20) // true cout << “3”; if(x ==10 || x ==14) // true cout << “4”; Prints: 234
const int RADIUS = 3.14; double num = 5.5; bool x = false; if(!x) RADIUS += 4; else num= 17; cout << num << endl;
const int RADIUS = 3.14; double num = 5.5; bool x = false; if(!x) RADIUS += 4; // ERROR! else num= 17; cout << num << endl;
int x = 4, y = 5; bool isWorking = false; if(x<y) if(isWorking) isWorking = false; else isWorking = true; else y = 20; cout << isWorking << endl;
int x = 4, y = 5; bool isWorking = false; if(x<y) if(isWorking) isWorking = false; else isWorking = true; else y = 20; cout << isWorking << endl; // Prints 1
What is the decimal equivalent of the following binary number?
What is the decimal equivalent of the following binary number?
Write 56 as a binary number.
** One more question
Write 56 as a hexadecimal number.
38
What does the code below print? for(int i = 0; i <= 3; i ++) cout << i;
What does the code below print? for(int i = 0; i <= 3; i ++) cout << i; //Prints:
What does the code below print? int x = 4; while(x < 10){ cout << x; x += 2; }
What does the code below print? int x = 4; while(x < 10){ cout << x; x += 2; } // Prints: 4 6 8
What does the code below print? for(int i = 0; i < 10; i *=2) cout << i;
What does the code below print? for(int i = 0; i < 10; i *=2) cout << i; // INFINITE LOOP
What does the code below print? int x = 5; while(x !=-1){ cout << x; x -= 2; }
What does the code below print? int x = 5; while(x !=-1){ cout << x; x -= 2; } // Prints: 5 3 1
Using interval notation, what range does the code below specify? rand() %
Using interval notation, what range does the code below specify? rand() % [10,20)
Using interval notation, what range does the code below specify? rand() % 5+15
Using interval notation, what range does the code below specify? rand() % 5+15 [15,20)
Using interval notation, what range does the code below specify? rand() % 7+50
Using interval notation, what range does the code below specify? rand() % 7+50 [50,57)
Using rand(), write a statement that creates a random number from [15, 20]
rand() %
Using rand(), write a statement that creates a random number in the interval: [50, 100)
rand() %
What does the code below print? int x = 0; while(x <5){ if(x % 2 == 0) cout << “$”; else cout << “#”; x ++; }
What does the code below print? int x = 0; while(x <5){ if(x % 2 == 0) cout << “$”; else cout << “#”; x ++; } // $#$#
What does the code below print? int x = 5; while(x < 10){ if(x % 3 == 0) cout << “$”; else cout << “#”; x ++; }
What does the code below print? int x = 5; while(x < 10){ if(x % 3 == 0) cout << “$”; else cout << “#”; x ++; } //Prints: #$##$
What does the code below print? int x = 0; while (x <= 4){ x++; cout<< x; }
What does the code below print? int x = 0; while (x <= 4){ x++; cout<< x; }// Prints: 12345
True/False A parameter of a function is a value that is passed into a function when the function is called.
Insert the correct line of code where indicated. void change (double); int main () { double amount; cout >amount; // Insert Code Here // return 0; }
Give me on possible answer! The purpose of a function header is to....
True/False The function that is called into use is called the called function.