Sunday, October 13, 2013

How to make a Triangle in C/C++.....

#include"stdafx.h"

#include"iostream"

#include"conio.h"

using namespace std;

int main()

{
    int n, i,  c, a = 1;

 

       cout<<"Enter the number of rows of Floyd's triangle to print\n";


    cin>>n;

    for (i = 1; i <= n; i++)
 
          {
        for (c = 1; c <= i; c++)  
            {

                 cout<<a;
               
                  a++;

             }
         cout<<"\n";

     }


  getch();

  return 0;
 }  

No comments:

Post a Comment