What is the output of the following program segment?
int count = 5;
while(--count > 0)
cout << count << " ";
cout << endl;
The output of the above C++ code segment is as follows:
Output : 4 3 2 1
While condition pre-decrements count value first then compares with 0.. which is (4 > 0) and till (1 >0) the condition remains true and prints count value.
What is the output of the following program segment? int count = 5; while(--count > 0)...
18 C++ 1. What is the output of the following program segment? int y-22: while ((y 3) != 0) cout << y<< "": y=y-2; The output is 2. Suppose that the input is 100, 20,-8, 50, 20. What is the output of the following C++ code? int sum0 int num: int j cin >> num: if (num < 0) continue зит зит + num; cout<< sum << endl; The output is
Thie What is the output of the following program segment? int count 1; do System.out.print(count (count-) + while(count++ <= 5);
What will the output be in the following? int a, b, c; a-b-0; c 5; ific< 1011 (a = = 0 &&b != 0)) 3. cout<<True"; else cout<<"False", What will the output be in the following? a. int icount; 4. do count = 0; cout<<"The count is "<cicount<<endl; while(icount<10); int count = 0; do b. cout<<"The count is “<<count<<endl; while++icount<10); c. for(int n 5; n>0; n-) cout<<n;
Given the following program segment: int limit = 4; int first = 5 int j; for (j=1; j <= limit; j++) { cout << first * j << endl; first = first + (j -1); } cout << endl; write a while loop and a do...while loop that both have the same output.
trace e following C++ program and provide the correct output: int x = 20, count=0; do { cout << x; x = 4* (x + 5)/5; count++; }while (count < 2);
5. What is the output of the following section of a program int a[10] = {2,5,1,6,x,7,0,3,y,8}; for(int i=0;i<9;i++) a[i]=a[i+1]; for(int i=0;i<8;i++) cout<<a[i]<<” “; cout<<endl; 6. What will be shown on the output screen after following statements are executed? char a[ ]="I have a part time job"; int c=x, i=0 while(a[i]!=’\0’){ if(a[i]==' '){ c++; cout<<endl; } else cout<<a[i]; i++; } cout<<c<<endl; 7. After following statements are executed, what are the outputs char a[ ]= "Fresno City College"; for (i...
31. The following code segment is syntactically correct: int number{20}; cout << number << setbase(16) << " " << number << setbase(10) << " " << number << showpos << " " << number << endl; T__ F__ 32. The following statement wants to determine if ‘count’ is outside the range of 0 through 100: if (count < 0 && count > 100) T__ F__ 33. There is...
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...
What does the following nested loop structure output? count = 1; while (count <= 11) {innerCount = 1 while (innerCount <= (12 - count)/2) {cout << " "; innerCount++;} innerCount = 1; while (innerCount = 1; while (innerCount <= count) {cout << "0"; innerCount++;} cout << endl; count++;} What does the following nested loop structure output? count = 1; while (count <= 10) {innerCount = 1; while (innerCount <= 10) {cout << setw(5) << count * innerCount; innerCount++;} cout <<...
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++