Friday 21 October 2011

Howto Make a Triangle c++ program

Howto Make a Triangle c++ program. In a applications, sometimes we use the statement for that also in the statement for. Such a situation is also often referred to as nested for or for nesting. One Example snippet for the use of nested syntax can be seen in star triangle below:


#include <iostream.h>
#include <conio.h>

void main()
{
 int tinggi; //untuk tinggi segitiga
 clrscr();

 cout<<"Masukkan Tinggi Segitiga = "; cin>>tinggi;
 cout<<endl;
 for(int baris=1; baris<= tinggi; baris++)
 {
  for(int kolom=1; kolom<=baris; kolom++)
  {
   cout<<" * ";
   cout<<endl;
  }
 }
 getch();
}



you can see, it's so easy . thanks for reading.

No comments:

Post a Comment