click below
click below
Normal Size Small Size show me how
M6ISS NA KITA
Miss na kita balik kana pls
| Question | Answer |
|---|---|
| If the test occurs at the beginning of the loop, the type of loop is called a post-test loop or entrance-controlled loop. | False |
| Consider the ff. output: 0 3 6 9 What is the code snippet for the above output? | for(int x=0;x<12;x++) { cout<<x<<” “; x++; x++; |
| imulate 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 | 8 |
| If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block? | braces { } |
| 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<<"\ | 6 |
| Condition in for loop is evaluated on each loop iteration, if the condition is false then the statements inside the for loop body gets executed. | False |
| Which of the following while clauses tells the computer to exit the loop when the value in the age variable is greater than or equal to the number 0? | while (age >= 0) |
| What is the output of C++ Program? #include<iostream> using namespace std; int main(){ int a=5; while(a==5) { cout<<"PROGRAM"; break; } return 0; } | PROGRAM |
| Which looping process is best used when the number of iterations is known? | for |
| How many times 'its a while loop' should be printed? int main() { int i = 1 ; i = i - 1 ; while(i) { cout<<"its a while loop"; i++ ; } return 0; } | 0 |
| How many times will the computer process the cout << numTimes << endl; statement in the following code? int numTimes = 0; while (numTimes > 3) { cout << numTimes << endl; numTimes =numTimes + 1; } | 0 |
| What is the output of C++ Program? #include<iostream> using namespace std; int main(){ int a=5; while(a >= 3); { cout<<"RED\n"; break; } cout<<"GREEN"; return 0; } | There’s an error. |
| 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 << "va | 19 |
| 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? | braces { } |
| If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block? | braces { } |
| In a group of nested loops, which loop is executed the most number of times? | the innermost loop |
| int i = 0; do{ cout << i; i++; } while (________); | i < 5 |
| Each pass through a loop is called a/an ________ | iteration |
| The destination point is identified by a label, which is then used as an argument for the goto instruction. | True |
| 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 |
| What is the value of num after 3rd 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 | 19 |
| How many times is a do while loop guaranteed to loop? | How many times is a do while loop guaranteed to loop? Group of answer choices 0 It varies. 1 Infinite times |
| Do-while is a pre-test loop | False |
| In nested loop, the innermost statement is executed m x n times where m is the number of iterations of the outerloop and n is the number of iterations of the innerloop. How many times will the innermost statement be executed in the for (i = 1; i <=5 ; | 50 |
| How many times will the computer process the cout << numTimes << endl; statement in the following code? for (int numTimes = 1; numTimes < 6; numTimes++) cout << numTimes << endl; | 5 |
| 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<<"\ | 10 |
| Which for loop will cause an infinite loop? | for (i=5; i=10; i++) |
| 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; | 3;5;4 |
| 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<<"\ | 46 |
| 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; | 1 |
| 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<<"\ | 8 |
| A continue statement causes execution to skip to ______ | the next iteration of the loop |
| The loop iterates while the condition is true. | True |
| What is the final value of x when the code int x=0; while(x<10) {x++;} is run | 9 |
| When does the code block following while(x<100) execute? | When x is less than one hundred |
| Given the following segment of a program, determine how many times the code inside the loop has been executed int a = 4; while (a%2!=1) { cout<<a; a +=5; } | 2 |
| What is the code snippet 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<50) { sum=x+y; cout<<sum<<" "; x=y; y=sum; } |
| Given the following segment of a program, determine how many times the code inside the loop has been executed int x = 1; while (x>=0) { cout<<x; x - -; } | 2 |
| The loops become infinite and repeats itself indefinitely if the test expression is always false. | False |
| 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 do{ cout << "value of a: " | 19 |
| What should be in the blank to output 01234? int i = 0; do{ cout << i; i++; } while (________); | i < 5 |
| What's wrong? do{ } while( (i < 10) && (i > 24)) | the test condition is always false |
| Which loop is correct? | do {//code}while (condition); |
| What is the value of num after 3rd 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 | 7 |
| What is the effect of writing a break statement inside a loop? | It cancels remaining iterations |
| When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration. | True |
| goto statement allows making an absolute jump to another point in the program. Group of answer choices | True |
| A do-while loop that never stops is said to be the infinite while loop, when we give the condition in such a way so that it never returns ___, | False |
| continue statement is used to come out of the loop instantly | False |