dimanche 21 novembre 2021

Code only outputs a single row while trying to draw a rectangle

void fyllRektangel(int hojd, int bredd); 

    int main(){
        int hojd;       //Height
        int bredd;      //Width
        cin>>hojd;
        cin>>bredd;

        for(int r=1;r<=hojd;r+=1){
            for(int k=1;k<=bredd;k+=1)
                cout<<setw(4)<<"*";
            cout<<endl;



            return 0;
        }
    }

Why does my code only output a single row, but all the columns in my for loop? Im learning about patterns and the output is suppose to be of a rectangle where the width and height is input from the user.

Aucun commentaire:

Enregistrer un commentaire