Write a program in C++ using repetition structures to print the following pattern. You are not allowed to use nested loops. (USE WHILE LOOP OR DO WILE LOOP)
****
***-
**--
*---
#include <iostream>
using namespace std;
int main()
{
int i=0;
while(i<4){
cout<<"*";
i++;
}
i=0;
cout<<"\n\n";
while(i<3){
cout<<"*";
i++;
}
i=0;
cout<<"-\n\n";
while(i<2){
cout<<"*";
i++;
}
i=0;
while(i<2){
cout<<"-";
i++;
}
cout<<"\n\n";
i=0;
while(i<1){
cout<<"*";
i++;
}
i=0;
while(i<3){
cout<<"-";
i++;
}
cout<<"\n\n";
cin>>i;
return 0;
}
Comments
Leave a comment