Write a Programs to print triangles using numbers and characters
In this program we learn you how to make a triangle using the number and star;\
You must have basic knowledge of C++ programming language and variable , while loop and if..ealse and for loop
Example 1: write a Program to print triangle using *
*
* *
* * *
* * * *
* * * * *
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int i, j, rows;
cout<<" Please Enter the rows: ";
cin>>rows;
for(i=1; i<=rows; ++i)
{
for(j=1; j<=i; ++j)
{
cout<<"* ";
}
cout<<"\n";
}
return 0;
}
Output
------------------
Plaese enter the rows
6
*
* *
* * *
* * * *
* * * * * *
Example 1: write a Program to print triangle using number
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int i, j, rows;
cout<<"Please Enter the rows: ";
cin>>rows;
for(i=1; i<=rows; ++i)
{
for(j=1; j<=i; ++j)
{
cout<<j;
}
cout<<"\n";
}
return 0;
}
output
-----------------
Please enter the row
8
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
---------------------------------------------------------------------------------------------------
The people who want to learn programming language.this website very beneficial for those people.
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info post cards printing
ReplyDelete