vendredi 27 décembre 2019

V shape figure using nested for loop C++

I want to make a V shape diagram using nested for loop in C++. My code is below:

#include<iostream>
using namespace std;
int main()
{
    for(int i=0; i<5; i++)
    {
        for(int k=-i+5; k>5;k++)
        {
            cout<<' ';
        }
        cout<<'@';
        for(int j=i+2; j<7;j++)
        {
            cout<<' ';
        }
        cout<<'@'<<endl;
    }
}

Aucun commentaire:

Enregistrer un commentaire