Segitiga dengan Bahasa C


Program pertama

   1:   #include <stdio.h>
   2:  #include <conio.h>
   3:   
   4:   
   5:  void main()
   6:  {
   7:  int j,i;
   8:   
   9:  for (i=0; i<6; i++){
  10:      for(j=0;j<i;j++){
  11:      printf("*");
  12:      }
  13:      printf("\n");
  14:   
  15:      
  16:      
  17:  }
  18:   
  19:   
  20:      getch();
  21:  } 
  22:   

Program kedua

 

   1:  #include <stdio.h>
   2:  #include <conio.h>
   3:   
   4:   
   5:  void main()
   6:  {
   7:  int j,i,k,n;
   8:  n=5;
   9:   
  10:  for (i=0; i<=n; i++){
  11:      
  12:      for(k=0;k<=i;k++){
  13:          printf(" ");
  14:      }
  15:   
  16:      for(j=n;j>i;j--){
  17:   
  18:      printf(" *");
  19:      }
  20:   
  21:      
  22:   
  23:      printf("\n");
  24:   
  25:      
  26:      
  27:  }
  28:   
  29:   
  30:      getch();
  31:  } 
  32:   

Program ke tiga

   1:   #include <stdio.h>
   2:  #include <conio.h>
   3:   
   4:   
   5:  void main()
   6:  {
   7:  int j,i,k,n;
   8:  n=5;
   9:   
  10:  for (i=0; i<=n; i++){
  11:      for(j=n;j>i;j--){
  12:   
  13:      printf(" ");
  14:      }
  15:   
  16:      for(k=0;k<=i;k++){
  17:          printf("* ");
  18:      }
  19:   
  20:      printf("\n");
  21:   
  22:      
  23:      
  24:  }
  25:   
  26:   
  27:      getch();
  28:  } 
  29:   

Sumber bacaan dan contoh:

  1. http://rendramm2.wordpress.com/2009/10/21/program-segitiga-bintang-segitiga-pascal/
  2. http://terusbelajar.wordpress.com/2009/04/14/bintang-segitiga-dgn-bahasa-c/

One thought on “Segitiga dengan Bahasa C

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s