write a c++ program by using do-while loop!!
Answers
Answered by
0
#include <iostream>
using namespace std;
int main()
{
float number, sum = 0.0;
do
{
cout<<"Enter a number: "; cin>>number; sum += number;
}
while(number != 0.0);
cout<<"Total sum = "<<sum;
return 0;
}
using namespace std;
int main()
{
float number, sum = 0.0;
do
{
cout<<"Enter a number: "; cin>>number; sum += number;
}
while(number != 0.0);
cout<<"Total sum = "<<sum;
return 0;
}
Answered by
1
Answer:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i=1, n,j=1;
//loop for input
do
{
cout<<"\nEnter any number";
cin>>n;
i++;
}while(i<=10);
//loop for show
do
{
cout<<n<<endl;
j++;
}while(j<=10);
getch();
}
Points to note:
•do while statement is terminated by a semi colon ( ; )
•loop should have initialisation, condition, increment/decrement.
•it is an exit control loop.
Similar questions