Answer to Question #297445 in C++ for Sabeeha

Question #297445

Write a program that produces the following output:

CCCCCCC
C         +      +
C       +++++  +++++
C         +      +
CCCCCCC





1
Expert's answer
2022-02-13T17:11:58-0500

Solution with loop:

#include <iostream>
using namespace std;

int main() {
	for (int i = 1; i <= 5; i++) {
		if (i == 1 || i == 5)   cout << "CCCCCCC" << endl;
		else if (i == 2 || i == 4) cout << "C         +      +" << endl;
		else            cout << "C       +++++  +++++" << endl;
	}
}


Solution without loop:

#include <iostream>
using namespace std;

int main() {
	cout << "CCCCCCC" << endl;
	cout << "C         +      +" << endl;
	cout << "C       +++++  +++++" << endl;
	cout << "C         +      +" << endl;
	cout << "CCCCCCC" << endl;
}

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