Question & Answer: Question 4 Determine the value in total after each of the following loops i…..

Question 4 Determine the value in total after each of the following loops is executed a) double total -0: for (int i-l ; i<-10;i=i+1) g) double total int i=1 ; while (i<100) -O: total total + 1; b) double total0: for (int count-i:count<-10:count) total+ ; total- total 2 c) double total = 0; for (int icnt-i:icnt-8:++icnt) h) double total 0: int i=10; do total = total ,icnt; total+=20; while (1195 ) ; d) double totai - 1.0: for (int:-1:1(54 ; ++) ) total total /2.0 1) double total -0: int i-10 do e) double total- 0: int i=1; while (total<10) total-10: while (2- 00) ; total-total-i: 3) double total 0: double total 0: do while(L:00) total-10:
media%2Fc96%2Fc9602998-3511-4885-aaa1-f3 Dev C++

Question 4 Determine the value in total after each of the following loops is executed a) double total -0: for (int i-l ; i

Expert Answer

 

//final value of total is given below in output

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Question 4 Determine the value in total after each of the following loops i…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

a.cpp ——–>

#include<iostream>
using namespace std;
int main()
{
double total=0;
for(int i=1;i<=10;i=i+1)
total=total+1;
cout<<total;
return 0;
}

Output :-

10

b.cpp ——>

#include<iostream>
using namespace std;
int main()
{
double total=0;
for(int count=1;count<=10;count)
total=total*2;
cout<<total;
return 0;
}

Output :-

No Output

//total remain same 0 till infinite time

c.cpp ——>

#include<iostream>
using namespace std;
int main()
{
double total=0;
for(int icnt=1;icnt<=8;++icnt)
total=total*icnt;
cout<<total;
return 0;
}

Output :-

0

d.cpp ——>

#include<iostream>
using namespace std;
int main()
{
double total=1.0;
for(int j=1;j<=4;++j)
total=total/2.0;
cout<<total;
return 0;
}

Output :-

0.0625

e.cpp——>

#include<iostream>
using namespace std;
int main()
{
double total=0;
int i=1;
while(total<10)
{
i++;
total=total+i;
}
cout<<total;
return 0;
}

Output :-

14

f.cpp ——>

#include<iostream>
using namespace std;
int main()
{
double total=0;
int i=1;
while(i<100)
{
total+=1;
i+=2;
}
cout<<total;
return 0;
}

Output :-

50

g.cpp—–>

#include<iostream>
using namespace std;
int main()
{
double total=0;
int i=1;
while(i<100)
{
total+=i;
}
cout<<total;
return 0;
}

Output —->

No output as while loop will run infinite times becasue i will remain always less then 100

so total will be infinte.

h.cpp —->

#include<iostream>
using namespace std;
int main()
{
double total=0;
int i=10;
do
{
total+=20;
}while(i<=5);
cout<<total;
return 0;
}

Output —–>

20

i.cpp ——>

#include<iostream>
using namespace std;
int main()
{
double total=0;
int i=10;
do
{
total+=10;
}while(i<=100);
cout<<total;
return 0;
}

Output —->

No output so total will be infinite this time

j.cpp—–>

#include<iostream>
using namespace std;
int main()
{
double total=0;
int i=10;
do
{
total+=10;
i++;
}while(i<=100);
cout<<total;
return 0;
}

Output —–>

910

Still stressed from student homework?
Get quality assistance from academic writers!