do while
can anyone share with me on how to make a do while statement producing the sample output...
***
**
*
let X = 3;
do {
print X number of stars;
} while( X is at least 1 );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter the number of Stars: "<<endl;
cin>>num;
do {
for(int i=0; i<num;i++)
{
cout <<" * ";
}
num=num-1;
cout<<endl;
} while( num >= 1 );
return 0;
}
| |
Topic archived. No new replies allowed.