Solution A)
Initially i=3
Iteration | Value of i | i<10 | Result of i<10 | print i | i=i*2 | i=i+2 |
1 | 3 | 3<10 | true | 3 | i=6 | i=8 |
2 | 8 | 8<10 | true | 8 | i=16 | i=18 |
3 | 18 | 18<10 | false,loop ends |
Output:
3
8
Solution B)
Initially j=7, d=2 , sum=0
Iteration | Value of j | j>=0 | Result of j>=0 | sum=sum+d | j=j-1 |
1 | 7 | 7>=0 | true | sum = 0 +2 =2 | j = 7-1 =6 |
2 | 6 | 6>=0 | true | sum = 2 +2 =4 | j = 6-1 =5 |
3 | 5 | 5>=0 | true | sum = 4 +2 =6 | j = 5-1 =4 |
4 | 4 | 4>=0 | true | sum = 6 +2 =8 | j = 4-1 =3 |
5 | 3 | 3>=0 | true | sum = 8 +2 =10 | j = 3-1 =2 |
6 | 2 | 2>=0 | true | sum = 10 +2 =12 | j = 2-1 =1 |
7 | 1 | 1>=0 | true | sum = 12 +2 =14 | j = 1-1 =0 |
8 | 0 | 0>=0 | true | sum = 14 +2 =16 | j = 0-1 =-1 |
9 | -1 | -1>=0 | false, loop ends | ||
output:
16
or (int i - 3; i<ll; i-i+2) Solution: cout< iend; i-i2 B) What will the following...
What is the output? (3 pts) int num = 5; int* ptr = # cout << ptr << endl; cout << &ptr << endl; cout << *ptr << endl;
14.3 How many times is the statement cout<<]<<","<</<<","; executed in the following program? int I, ); for (I = 2; I >= 0; I--) { for (] = 1; }<2; J++) cout << ) << ", << I << cout << endl; 11 } Select one O 2.3 0 6.6 O c. 2 d. None of the above are correct
What is the output of the following code: int numbers [] {99,87,66,55,101}; cout << numbers[i] « " ";
int arr[] = {1,4, 1, 0); for (int i=0; i < 4; ++i) cout<<arr[i]*2; 0140 1014 1410 (space in between each number) 1410 None of the above void square(int &n){n= n*n;} int arr[] = {1, 2, 3}; int number = 4; Which of the following function calls are acceptable? square(1); square(arr[number]); square(number); square(2);
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...
homework c++ find the error/correction void Showval (int n) for (int i = 0; i<10;-) cout <<n [i; )
What is the output of the following? int sum=3, z=1; do { printf("The sum:%d*", sum+z); } while (sum<= 1); printf("0"); * 1 (2 Points) 40 4
What is the output of the following code fragment? int i = 1; while( i <= 5 ) if(i == 2 || i == 4) System.out.println(i + ":" + " is an even index) System.out.println("i: " + i); i++;
What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday";
Please show all steps for #15 and #16 neatly. Thank you so much in advance! Will rate thumbs up for correct answer ! ? 15. Determine the output of th ollowing Ct+ code? int num346, sum 0; do wA sum-sum + num % 10; num = num / 10; cout < sum endl; while (num> e); rmine the output produced by the following code fragment? int i 11; i 1 i 4)10 9 cout << i << " ". i+t;...