3)
The output will be "True". This is because in the program,The variables are initialised as follows:
a=0
b=0
c=5
Now, in the if condition, c<10 evaluates to true. remember, if any field in the or (||) expression evaluates to true, then if block will run irrespective of the other expression in the or statement.
So we, get the output as "True" since our if block will execute and not the else block.
4)
a)The output will be "The count is 0" infinite times. This is because in the do-while loop, we are not incrementing the value of icount. icount always remains 0, so our do-while loop will never terminate, as icount will always remain smaller than 10.
b)The output is:
The count is 0
The count is 1
The count is 2
The count is 3
The count is 4
The count is 5
The count is 6
The count is 7
The count is 8
The count is 9
This is because, as icount equals 10, the loop will terminate.
c)The output is: 54321
This is because, we are printing n 5 times, and n is decrementing
each time by 1 (initialised with 5).
If you liked the solution, don't forget to give a THUMBS UP!. In case of any doubt, please let me know in the comments section. I'll get it resolved :) :)
What will the output be in the following? int a, b, c; a-b-0; c 5; ific<...
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...
C++ What output does the following program produce? int getValue(int a, int b, int n); int main() cout << getValue(1, 7, 7) << endl; return 0; } // end main int getValue(int a, int b, int n) int returnValue = 0; cout << "Enter: a = " < a << " b = " << b << endl; int c = (a + b)/2; if (C* C <= n) return value = c; else returnValue = getValue(a, C-1, n); cout...
Question 15 After the following code executes, what is the output if user enters 0? int x =-1; cout << "Enter O or 1:"; cin >> X; if (x) cout << true else cout << false O nothing will be displayed true O false 0
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);
A. What is the output of the following C++ code fragment? (all variables are of type int) int count-1; int y-100; while (count 3) y=y-1 ; count+t cout << y << endl; cout<< count <<endl What is the value of x after control leaves the following while loop? (all variables are of type int) B. int x0 while (x < 20) sum- sum+x cout << sum<< endl;
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++
What is the output?
points): Show the output of the code below as it would appear on the monitor. int main cout <<" <<endl: int wildcat 2: while (wildcat > 5) cout << wildcat <<endl; wildcat++ cout <K*<< endl; int jayhavk 5i do cout << jayhawk <s endl: while (jayhawk0) cout <<*" << endl; int wolverine l: while (wolverine 0 &&wolverine < 10) cout << wolverine <<endl: wolverine2: cout <<" <<endl: for (int zag-4; zag>0; zag_) cout <<****" << endl; for (int i-10; i<-30;...
11) What is the output of the following Che statements? void Exam(int N) { int list1[3] { 2, 4, 6); if (NX2 - 0) cout << listi[N - 1); else cout << listi[N 5):) void main() { int list[3] - (1, 3, 5); Exam(list[2]);} A) 2 B) 4 C) 6 D) 3 12
Suggested time to spend 5 min) What will be the output of the following program #include <iostrean using namespace std; int main() { int 16: bool printe; for (int i=2; i<n; i++) { prine = true; for (int 1-2; 14; j++) if () == ) { prine = false; jut; } if (prine) cout << i << endl; return 0; } Arial . 3 (12) T TTTF Paragraph YLE