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

COMP PROG SA 4

Reviewer

QuestionAnswer
What is the code snippet that will print all numbers from 1 - 100 in reverse in vertical manner? 1. for (int x = 101; x > 0; x--) cout << x << endl; 2. for (int x = 100; x > 1; x++) cout << x << endl; 3. for (int x = 100; x > 0; x--) for (int x = 100; x > 0; x--) cout << x << endl;
int x = 1, y = 2, z = 3; for int (ctr = 1; ctr <= 10; ctr++) { cout << ctr << " iteration" << endl; cout << "\t x = " << x << endl; cout << "\t y = " << y << endl; cout << "\t z = " << z << endl; x += y; y += z; z += ctr; } If the condition ctr 0
Simulate the following code snippet: int a = 1, b = 1, c = 1; for(int ctr = c; ctr <= 10; ctr++) { cout << ctr << " iteration" << endl; a++; b += 5; c += a; cout << "\t a = " << a << endl; cout << "\t b = " << b << endl; cout << "\t c = " << c << 51
Given the following code snippet: for (x = 1; x <= 1000; x++) cout << x << endl; What will you do to modify the given code that will only print multiples of 100. Put an if statement that will check if the value is divisible by 100. (?)
Simulate the following code snippet: int x = 1, y = 2, z = 3; for (int ctr = 1; ctr <= 10; ctr++) { cout << ctr << " iteration" << endl; cout << "\t x = " << x << endl; cout << "\t y = " << y << endl; cout << "\t z = " << z << endl; x += y; y += 1;2;3
Which for loop will cause an infinite loop? 1. for (i = 5; i <= 10; i++) 2. for (i - 5; i > 0; i--) 3. for (i = 0; i < 5; i++) 4. for (i = 5; i = 10; i++) for (i = 5; i = 10; i++)
What is the correct syntax of for loop? for (initialization; condition; increment/decrement)
Simulate the following code snippet: int a = 1, b = 1, c = 1; for (int ctr = c; ctr <=10; ctr++) { cout << ctr << " iteration" << endl; a++; b += 5; c += a; cout << "\t a = " << a << endl; cout << "\t b = " << b << endl; cout << "\t c = " << c << 66
TRUE OF FALSE: After every execution of for loop's body, the increment/decrement part of for loop executes that updates the loop counter TRUE (?)
The statement i++; is equivalent to ___________ - i = i + i; - i = i + 1; - i = i - 1; - i--; i = i + 1'
What is the output of the C++ Program? #include <iostream> using namespace std; int main() { while (true) { cout << "C++"; break; } return 0; } C++
What is the output of the C++ Program? #include <iostream> using namespace std; int main() { int a = 25; while (a <= 27) { cout << a << " "; a++; } return 0; } 25 26 27
Which looping process is best used when the number of iterations is known? 1. do-while 2. while 3. all looping processes require that iterations be known 4. for for
A while loop that never stops is said to be the infinite while loop, when we give the condition in such way so that it never returns ______. False
If there is more than one statement in the block of a while loop, which of the following must be placed at the beginning and the ending of the loop block? - angle brackets < > - parentheses ( ) - brackets [ ] - braces { } braces { } (?)
What is the code that will print this output: 1 2 3 5 8 13 21 34 55 int sum = 0; int x = 1, y = 2; cout << x << " " << y << " "; while sum (sum < 50) { sum = x + y; cout << sum << " "; x = y; y = sum; }
What was the last value of a that was printed on screen? #include <iostream> using namespace std; int main() { // Local variable declaration: int a = 10; // while loop execution while (a < 20) { cout << "value of a: " << a << endl; a++; } retur 19
What is the output of this C++ Program? int var = 1; while (var <= 1) { cout << var; var++; } 1
What is the value of num after the 5th iteration? #include <iostream> #include <math.h> using namespace std; int main() { int num = 1; while (num <= 20) { cout << "Num: " << num << endl; num += 3; } return 0; } 13
Which looping process checks the test condition at the end of the loop? 1. do-while 2. for 3. while 4. no looping process checks the test condition at the end of the loop do-while
What is the effect of writing a break statement inside a loop? It cancels remaining iterations (?)
TRUE OR FALSE: A loop becomes infinite loop if a condition never becomes true FALSE
A continue statement causes the execution to skip to ________ the next iteration of the loop
#include <iostream> using namespace std; int main() { int a = 32; do { cout << a << " "; a++ if (a > 35) break; } while(1); return 0; } 32 33 34
What is the value of num after the 5th iteration? #include <iostream> #include <math.h> using namespace std; int main() { int num = 1; do { cout << "Num: " << num << endl; num += 3; } while (num <= 20); return 0; } 19
What should be in the blank to output 01234? int i = 0; do { cout << i; i++; } while (_______); i < 5
What numbers will the following code display on the computer screen? int x = 20; do { cout << x << endl; x = x -4; } while (x > 10) 20, 16 ,12
continue statement is used to come out of the loop instantly FALSE (?)
What is the value of num after 3rd iteration? #include <iostream> #include <math.h> using namespace std; int num = 1; do { cout << "Num: " << num << endl; num += 3; } while (num <= 20); return 0; } 7
Determine the output. s = 0; for (j = 1; j < 3; j++) s = s + j * j; cout << s; 5
Simulate the following code snippet int x = 1, y = 2, z = 3; for (int ctr = 1; ctr <= 10; ctr++) { cout << ctr << " iteration" << endl; cout << "\t x = " << x << endl; cout << "\t y = " << y << endl; cout << "\t z = " << z << endl; x += y; y += z 10
Created by: reeper
 

 



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