21 March, 2012

C++ Program To Print Asterisks Graph.

This Post Contains A C++ Program To Print Asterisks Graph With Correct Source Code & Output. This Program Is Written, Compiled & Executed At TurboC/C++3.0 Compiler & Will Help You To Understand The Concept Of 'For-Loop' & 'Nested Loops' From C++ Language. It Is A Well-Structured Program With Proper Comments Which Provides Step-By-Step Description Of Various Features Of The Language In A Simple & Easy-To-Understand Way.

# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.


C++ Program To Print Asterisks Graph.

/* Declaration Of Header Files */
# include <iostream.h>
# include <conio.h>

/* Start Of Main Program */
void main()
{
                /* Declaration Of Variables */
                int i, j, r;
                clrscr();

                /* Asking For The Input From User */
                cout << " Enter No. Of Rows : ";
                cin >> r;

                /* Source Code For Printing Asterisks Graph */
                for (  i  =  0;  i  <  r;  i++  )
               {
                               cout << " \n ";
                               for (  j  =  0;  j  <=  i;  j++  )
                              {
                                           cout << " * ";
                               }
               }
               getch();
}
/* End Of Main Program */

Ouput :

Enter No. Of Rows :

*
*     *
*     *      *
*     *      *      *
*     *      *      *      *







No comments:

Post a Comment

Subscribe To:

Most Commonly Asked Programs In 'C' & 'C++' Language.