Save
Upgrade to remove ads
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

CCS3 - Mod5

Reviewer

QuestionAnswer
Consider the following code snippet int a,b,c,max; max=a; if(max<b) max=b; if(max<c) max=c; cout<<”Max: ”<< max; What output do you think the code will produce if a is 10, b is 20, c is 30? Max: 30
What does the following code fragment write to the monitor? int sum = 94; if ( sum < 20 ) { cout<<"Under "; cout<<"the limit."; } else { cout<<"Over "; cout<<"the limit."; } Over the limit.
Assume the following initialization: x = 2, y = 3. Determine the output of the given segment of a program. if ( x >= y ) if( y >= 0 ) cout<<”y = “<<y; else cout<<”x = “<<x; No screen output
What does the following code fragment write to the monitor? int sum = 14; if ( sum < 20 ) cout<<"Under "; else cout<<"Over "; cout<<"the limit."; Under the limit.
Consider the following code snippet if (x<50) if (x>=0 && x<=25) x+=25; else x-=25; What will be the final value of x if x=33? 8
If none of the conditions is true in an if-ladder then the final else statement will be executed. True
if (aNumber >= 0) if (aNumber == 0) cout<<"first string\n"; else cout<<”second string\n”; cout<<"third string"; What output do you think the code will produce if aNumber is 3? second string third string
Whether the indentation exists or not, the compiler will, by default, associate an else with the closest previous unpaired if. True
What is the variable used in the program? float grade; grade
If grade = 68, what will be its output? if (grade>=95) { cout<<"Excellent"; else if(grade>=90) cout<<"Very Good"; else if(grade>=85) cout<<"Good"; else if(grade>=75) cout<<"Fair"; else cout<<"Study very well."; return 0; } Study very well.
int x = 4, y; switch ( y % x ){ case 0: x += y; case 1: cout<<“x = ” << x;break; default: cout<<”No Match”; } What is the output of this program if y = 5? x = 4
int id = 0; cout << “ID: “; cin >> id; switch (id) { case 3: case 5: cout << “Jerry”; break; default: cout<<"Sue"; What will be displayed when the user enters the number 3? Jerry
The constant-expression for a case must be of different data type as the variable in the switch. False
#include<iostream> using namespace std; int main(){ int num; cout<<"Enter a number:"; cin>>num; switch(num){ case 1: cout<<"RED";break; } return 0; } If num=-1, what will be its output? No screen output
Which of the following must be present in the switch construct? default
When you have the default keyword in your switch, you are required to place a break statement. True
Switch case statement is used when you only have one condition. False
#include<iostream> using namespace std; int main(){ int num; cout<<"Enter a number:"; cin>>num; switch(num){ case 1: cout<<"RED"; break; } return 0; } What is the output of this program if y = -2? No Match
Consider the following switch statement: int x = 4, y; switch ( y % x ) { case 0: x += y; case 1: cout<<“x = ” << x;break; case 2: y -= x; case 3: cout<<“y = ” << y; break; default: cout<<”No Match”; } No Match
int a, b=2, c; switch ( a/b ) { case 0: a += b; case 1: cout<<“a = ” << a;break; case 2: c = a/b; case 3: cout<<“c = ” << c;break; default: cout<<”No Match”; } What is the output of this program if a = 16? No Match
int a, b=2, c; switch ( a/b ) { case 0: a += b; case 1: cout<<“a = ” << a;break; case 2: c = a/b; case 3: cout<<“c = ” << c;break; default: cout<<”No Match”; } What is the output of this program if a = 8 and b = 4? c = 2
Consider the following code snippet if (x<50) if(x>=20 && x<40) x+=25; else x-=25; else x++; What will be the final value of x if x=75? 76
Determine the output of the given program segment. Assume the following initialization: int x = 5, y = 3; if ( x < y || x - y < x ) { x *= y; cout<<"x = " << x; } else { y += x; cout<<"y = " << y; } x = 15
Fill in the blank so people under 21 years are offered Grape Soda. int age = 17 ; if ( age _________ 21 ) cout<<"Care for some Grape Soda?"; else cout<<"How about a Brewski?"; <
Consider the following code snippet if (x<50) if(x>=20 && x<40) x+=25; else x-=25; else x++; What will be the final value of x if x=25? 50
Consider the following code snippet if (x<50) if(x>=20 && x<40) x+=25; else x-=25; else x++; What will be the final value of x if x=33? 58
Consider the following code snippet if (x<50) if(x>=20 && x<40) x+=25; else x-=25; else x++; What will be the final value of x if x=69? 70
Determine the output of the given program segment. Assume the following initialization: int x = 5, y = 3; if ( y < x && y – x < 0 ) { x /= y; y %= x; cout<<”x+y = “ <<x+y; } x+y = 1
int a,b,c,max; max=a; if(max<b) max=b; if(max<c) max=c; cout<<”Max: ”<< max; What output do you think the code will produce if a is 99, b is 50, c is 20? Max: 99
To make the multiple statements become compound statement, enclosed the statements with brackets []. False
int x = 4, y; switch ( y % x ){ case 0: x += y; case 1: cout<<“x = ” << x;break; case 2: y -= x; case 3: cout<<“y = ” << y; break; default: cout<<”No Match”; } What is the output of this program if y = 2? y = -2
How many choices are possible when using a switch case statement? 1 or more
Which of the following must be present in the switch construct? Expression in ( ) after switch
If no break appears, the flow of control will fall through to subsequent cases until a break is reached True
Every case needs to contain a break False
What value is assigned to discount? double discount; string code = "A" ; switch ( code ) { case 'A': discount = 0.0;break; case 'B': discount = 0.1;break; case 'C': discount = 0.2;break; default: discount = 0.3; } The program will not compile because code is the wrong type.
Consider the following code snippet switch (day) { case 1 : cout<<"Sunday";break; case 2 : cout<< "Monday";break; default : cout<<"Not an allowable day number";break; } What output do you think the code will produce if day is 20? Not an allowable day number
int a, b=2, c; switch ( a/b ) { case 0: a += b; case 1: cout<<“a = ” << a;break; case 2: c = a/b; case 3: cout<<“c = ” << c;break; default: cout<<”No Match”; } What is the output of this program if a = 5? c = 2
int number = 0; cout << “Number: “; cin >> number; if (number <= 100) number *= 2; else if (number > 500) number *= 3; If the user enters the integer 90, what value will be in the number variable after the code is processed? 180
What does the following code fragment write to the monitor? int sum = 21; if ( sum == 20 ) { cout<<"You win "; } else { cout<<"You lose "; } cout<<"the prize."; You lose the prize.
What does the following code fragment write to the monitor? int height = 10; if ( height <= 12 ) cout<<"Low bridge: "; cout<<"proceed with caution."; Low bridge: proceed with caution.
Consider the following code snippet if (x<50) if (x>=0 && x<=25) x+=25; else x-=25; else if (x>=75 && x <= 100) x-=25; else x+25; What will be the final value of x if x=25? 50
What does the following code fragment write to the monitor? int sum = 21; if ( sum != 20 ) cout<<"You win "; else cout<<"You lose "; cout<<"the prize."; You win the prize.
What does the following code fragment write to the monitor? int sum = 14; if ( sum < 20 ) cout<<"Under "; else { cout<<"Over "; cout<<"the limit."; } Under
Which of the following is not a program control structure? selection instantiation repetition invocation instantiation
The break statement causes an exit ________ from the innermost loop or switch.
In switch if there is a match, the associated block of code is executed True
Created by: PipoyKuraku
 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards