Write a program that produces the following output:
CCCCCCC
C         +      +
C       +++++  +++++
C         +      +
CCCCCCCSolution 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;
}
Comments