The output is as follows:
Initially x=0 . It satisfies the while condition and enters the loop.
It prints 0 and increments x to 1 and prints it . This goes on until x becomes 5 . At x=5 the while condition is not satisfied and execution ends.
II. SHORT ANSWER QUESTIONS. (10, 2 POINTS FOR EACH QUESTION) 1. What will the following loop...
C++ 5.How many times will the following loop run? int i=5; while (i19) 6 . What is the output of the following code snippet? int time 1; int year2 int rate = 1; int principal = 5; int interest-0 cout <<i < endl while (year< 5) interest (principal * time rate) /1 ; cout << interest << endl; year++
1) What will each of the program segment display int x = 1; while (x < 10); x++; cout << x; int x = 1; while (x < 10) X++; cout << x;
Q. 07 (2 points) Convert the following while loop to a for loop: int count = 0; while (count<50) cout<<"count iscounts endl count+
Please answer both questions thank you. Rewrite the following for loop into a while loop: int s S = 0; for (int i = 1; i <= 10; i++) { S += i; int s = 0; int i = while (i <= 10) S = + i; i++; } int s = 0; int i = 1; while (i <= 10) { s = s + i; i++; } int S = 0; int i = 1; while (i...
How many Iterations will this while loop perform? int ico), j(10); cout << "i = " << i << endl; cout << "j = " << j << endl; while (i > j) { cout << "j-" « j << endl; j += 2; cout << "i = " << i << endl; } cout << "i = << i << endl; cout << "j = " << j << endl; 5 6 C 8 10 Infinite times Does the...
What is the output of the following C++ code? int count = 1; int num = 25; while (count < 25) { num--; count++; } cout << count « " " « num << endl i 25 1 0 24 1 0 25 0 0 24 0 In this while loop statement, while (counter < 10), where counter is an int variable. Which statement below is an equivalent way to write this while statement? while (10 < counter) while (9...
Can you answer this question? The program is below. c) 2) What is the significace of the &' in front of parameter x? berOW. int a=2; int b = 7; myFun( a, b); cout << "a"<<a < endl; cout << "b<b endl void myFun int &x, int y ) =x+y;
What is the output?
c++ convert do while loop below to a for loop #define MAX VALUE 5 #define START VALUE 5 //START_VALUE always <-MAX VALUE int main() convert do while loop below to a for loop int j - MAX VALUE; do cout <<<<endl; ; while > 0); I
5.2 How many times this for loop will execute? for (i = 0; i <= 100; i++) ANN cout<<i+8<<endl; WA Am } Answer: