So I'm having trouble with this program. I have to print all the variations (check the image: https://gyazo.com/c28fec509d5647d8f179a55c29ac4d91 ). I've completed (a and (b, but I have no idea about (c and (d. Can you help out, please?
#include <iostream>
int main()
{
constint N {10};
for ( int row = 0; row < N; ++row ) {
for ( int col = 0; col <= row; ++col ) {
std::cout << '*';
}
std::cout << '\n';
}
std::cout << "----\n";
for ( int row = 0; row < N; ++row ) {
int col {0};
while ( col < 7 ) {
std::cout << '=';
++col;
}
while ( col < N ) {
std::cout << '*';
++col;
}
std::cout << '\n';
}
return 0;
}
Second, pay attention to lines 17-26. They print one line. The first loop advances the 'col' to 7 (and prints 7 characters) and the second loop advances the 'col' al the way to N (printing N-7 characters). Each line prints N characters.
You obviously do not want to print 7 whitespace and N-7 * on each line. You have to replace 7 with something more appropriate.