Creating a horizontal equilateral triangle [C++]
This program is use C++ Language, where we input T for triangle, in this program is using symbol '*', you can edit by number or else. This is the code :
#include<iostream.h>
#include<conio.h>
void main()
{
int tinggi;
int a=0,b,k;
cout<<" ==Program untuk membuat segitiga sama sisi=="<<endl;
cout<<"\nMasukan Tinggi Segitiga : ";
cin>>tinggi;
cout<<endl;
b=tinggi;
for(int i=0;i<tinggi;i++)
{
for(k=0;k<=i;k++)
{
cout<<'*';
}
cout<<endl;
}
for(i=tinggi;i>0;i--)
{
for(k=i-1;k>0;k--)
{
cout<<'*';
}
cout<<endl;
}
getch();
}
Hopefully can help :)
Subscribe to:
Post Comments (Atom)
ABOUT ME
Albert Julius. Powered by Blogger.
0 comments:
Post a Comment