C++: #CoolCodez Part 3

SITUATION: MAKING A RIGHT ANGLE TRIANGLE OF NUMBERS AND ALPHABETS.

Screen Shot 2017-10-15 at 12.46.31 PM.png

#include
#include
void main()
{ 
       clrscr(); 
       int row, temp=0, space, num=1, tempnum=1, cois; 
       char alpha='A', tempalpha='B';
 
       cout<<"\n\n";          for(row=5;row>0;row--) 
       { 
              if(row%2==0) 
              { 
                      tempnum--; 
                      num=tempnum; 
              } 
              else 
              { 
                      tempalpha--; 
                      alpha=tempalpha; 
              } 
              cout<<"\t";                              for(space=temp;space>0;space--) 
              { 
                      cout<<"\t";                               }                               temp++;                               for(cois=row;cois>0;cois--) 
              { 
                      if(row%2==0) 
                      { 
                              cout<<"\t"<<alpha++; 
                      } 
                      else 
                      { 
                              cout<<"\t"<<num++; 
                      } 
              } 
              tempalpha=alpha; 
              tempnum=num; 
              cout<<"\n"; 
        } 
        getch();
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s