print letter T using for loop in c++ language

Write a program that reads in a number and prints out the letter T using '*' characters with each line in the T having width n.  Further, the length of the horizontal bar should be 3n, and that of the vertical bar 2n.  




#include<iostream>

using namespace std;

int main()

{  //Double slash is used to give comment in c++ language.
   long i,j,k,n,x,z;

  cout<<"enter the value of n: ";
  cin>>n;

  for(i=0;i<n;i++)          //this loop is used to print n number of  rows

  {
     for(j=0;j<3*n;j++)    //this loop is used to print 3*n number of columns

    {cout<<"*";}

   cout<<endl;                //endl moves the cursor to next line.

  }

  for(k=0;k<2*n;k++)    //this loop is used to print 2* n number of  rows

  {

    for(z=0;z<n;z++)        //this loop is used to print n number of columns

     {cout<<" ";}

    for(x=0;x<n;x++)        //this loop is used to print n number of columns

     {cout<<"*";}

   cout<<endl;             

  }

return(0);

}





OUTPUT:























THANKYOU

Comments

Popular posts from this blog

CODE to print rhombus in python

printing triangle pattern using for loops in c++

CODE to Print a square(hollow) in python