Answer to Question #317600 in C++ for Zaki

Question #317600

Write a program in C++ using repetition structures to print the following pattern. You are not



allowed to use nested loops.



****



***-



**--



*---



By using do while loop

1
Expert's answer
2022-03-26T14:02:01-0400


#include <iostream>
using namespace std;


int main()
{
	int i=0;


	do{
		cout<<"*";
		i++;
	}while(i<4);
	i=0;
	cout<<"\n\n";
	do{
		cout<<"*";
		i++;
	}while(i<3);
	i=0;
	cout<<"-\n\n";
	do{
		cout<<"*";
		i++;
	}while(i<2);
	i=0;
	
	do{
		cout<<"-";
		i++;
	}while(i<2);
	cout<<"\n\n";
	i=0;
	do{
		cout<<"*";
		i++;
	}while(i<1);
	i=0;
	do{
		cout<<"-";
		i++;
	}while(i<3);
	cout<<"\n\n";




	cin>>i;
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog