Answer to Question #270983 in C++ for DANISH

Question #270983

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)

****

***-

**--

*---



1
Expert's answer
2021-11-24T13:48:13-0500


#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;
}

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
APPROVED BY CLIENTS