Search code examples
c++shapes

Create a shape in C++


I want to create a shape like this:

ccccccc
cccccc
ccccc
cccc
ccc
cc
c

My code is:

#include <iostream>

using namespace std;

int main(){
    int i, j;
    for(i = 0; i < 7; i++){
        for(j = 7; j > 7; j--){
            cout << 'c';
        }
        cout << endl;
    }
    return 0;
}

But in terminal the output I get is some blank lines.

What am I doing wrong?

enter image description here


Solution

  • for(j = 7; j > 7; j--){ This expression is always false.

    You need to write for(j = 7; j > i; j--){