What will be the value of sum after the following program is executed ?
void main ( )
{
int sum, i ;
sum = 1 ;
i = 9 ;
do {
i = i - 1 ;
sum = 2 * sum ;
}
while (i > 9) ;
cout << sum ;
}
a) 1 b) 2 c) 9 d) 0.5
Answers
Answered by
0
Answer:
9
Explanation:
hshsndjsbhsnajajsvsnsbdjsbsnd. dndnsnx d
Answered by
0
Answer:
void main option (b) is correct
Explanation
void main ( )
{
int sum, i ;
sum = 1 ;
i = 9 ;
do {
i = i - 1 ;
sum = 2 * sum ;
}
while (i > 9) ;
cout 9 and the value of I is initialized to 9 and decremented, the result of sum after the program has run is 2.
Option (a) cannot be true.
The while loop condition is bigger than 9, hence the value of sum after the program runs is not 1.
Option (c) cannot be chosen.
The while loop condition is bigger than 9, hence the value of total after the program runs is not 9.
Option (d) cannot be used
Because the while loop condition is greater than 9, the value of sum after the program runs is not 0.5.
#SPJ3
https://brainly.in/question/29236023
Similar questions