IV. Show the output of following programs. 1) #include <iostream.h> #include <io
ID: 3734310 • Letter: I
Question
IV. Show the output of following programs.
1)
#include <iostream.h>
#include <iomanip.h>
int main ()
{
int c = 0;
for (int i=0,j= 1; (i <=4 && j <=5); )
{
c += i+j;
cout << setw (5) << ++i << setw (5) << c << endl;
}
return 0;
}
____________________________________________________________
#include <iostream.h>
int main ( )
{
int y =0;
int x =1, total =0;
while ( x <= 6)
{
y +=x ;
cout <<"Y ="<< y <<endl;
total += y;
++x;
}
cout << "Total is = " << total << endl;
return 0;
}
Explanation / Answer
1)
1 1
2 3
3 6
4 10
5 15
2)
Y =1
Y =3
Y =6
Y =10
Y =15
Y =21
Total is = 56
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.