Description: This program shows how to draw triangle using natural numbers of user defined height.
Code:
//Compiling Tool: Code::Block IDE with MinGW
//Program draws triangle of user given height.
#include<iostream>
#include<conio.h> //for getch()
#include<cstdlib> //for system()
using namespace std;
int main()
{
system("cls");//to clear the screen
int i, j , z;
cout << "Enter height of triangle:_";
cin >> z;
for (i = 1; i <= z ; i++)
{
for ( j = 1 ; j <= i ; j++)
{
cout << j ;
}
cout << endl;
}
cout<<endl<<"Press any key to terminate program";
getch();
return(0);
}
Output:
If you want to write or construct or program C++ mini-project and do not know how or from where to start buy this simple e-book: Code Review of 26 C++ mini-projects. For book sample click this link.
Add your comments in below available comment box.
Note: Click these label/tags to view all related posts. Tags: C++Code
…till next post, bye-bye & take care.
No comments:
Post a Comment