0
Write a program using nested loop to give output as a given below through C++. Course
A A A A A A A A A A A A A A A A
1 Answer
+ 5
#include <iostream>
using namespace std;
void printSpaces(int i) {
for(int j = 0; j < i; ++j) {
cout << " ";
}
}
void printA(int i) {
for(int j = i; j < 7; ++j) {
cout << "A";
printSpaces(1);
}
}
int main() {
for(int i = 0; i < 8; i+=2) {
printSpaces(i);
printA(i);
cout << endl;
}
return 0;
}