Question

How many Iterations will this while loop perform? int ico), j(10); cout << i = << i << endl; cout << j = << j << endl;

Does the following program contain a syntax error? If the program does contain a syntax error then answer True. Otherwise ans

What would be the first line (see /* FILL IN YOUR ANSWER HERE */ below) of the following for loop: for ( FILL IN YOUR ANSWER

How many times will the following code output J is 2 to the screen? int i(1); while (i <= 4){ cout << i is << i << endl;
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans) option A

Explaination:- The while loop will run 0 times as the value of i=0 and j = 10. The conditon of the loop is while(i>j). Here the value of i is less than j, so the loop will not get executed.

Ans) True

Explaination:- There is a syntax error in the code. The scope of variable i is limited to the for loop as it is declared inside the loop. So, accessing it after the loop to print i,e cout<<i will give an error that the variable is out of scope.

Compile Errors : prog.cpp: In function int main(): prog.cpp:9:8: error: i was not declared in this scope cout<<i<<endl; T

Ans) for( int k(1) ; k<=6;k++)

Explaination:- This for loop is equivalent to the while loop given. The for loop wil start with k=1 and run the loop till k=6 and increment the value of k after each iteration.

Ans) 4 times

Explaination:- The outer while loop wil run for 4 times and the inner while loop will print " j is 2" one time each. Therefore total times will be 4*1= 4.

L.lı Result $g++ -o main *.cpp $main Execute 1 > Share main.cpp STDIN 1 #include <iostream> 2 using namespace std; 3 4 int ma

Add a comment
Know the answer?
Add Answer to:
How many Iterations will this while loop perform? int ico), j(10); cout << "i = "...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT