Monday 17 October 2011

Printing of Isosceles Triangle of Star

//prints isosceles triangle of star//
#include<stdio.h>
#include<conio.h>
main()
{
      int row, clm, space;
      for(row = 1; row <= 20; row+=2)
      {
               
              //printing spaces//
              for(space=18; space >= row; space-=2)
                      {
                              printf("%c",' ');
                      }
              //printing stars//
              for(clm = 1; clm <=(row); clm++ )
              {
              printf("*");
              }
       printf("\n");
      }
getche();
return 0;
}


Printing Right Angel Triangel of Stars (Right angel at upper right corner)

//prints triangle of star with right angle at upper right corner//
#include<stdio.h>
#include<conio.h>
main()
{
      int row, clm,space;
      for(row = 1; row <= 10; row++)
      {
              //printing spaces//
              for(space=2; space <= row; space++)
              {
                      printf("%c",' ');
              }
                     
              //printing Stars//
              for(clm = 9; clm >=row; clm--)
              {
                      printf("%c",'*');
              }
              printf("\n");
      }
getche();
return 0;
}


Printing Right Angel Triangel of Stars (Right angel at lower right corner)

//prints triangle of star with right angle at lower right corner//
#include<stdio.h>
#include<conio.h>
main()
{
      int row, clm, space;
      for(row = 1; row <= 10; row++)
      {
                      //printing spaces//
                      for(space=9; space >= row; space--)
                      {
                              printf("%c",' ');
                      }
                      //printing Stars//
                      for(clm = 1; clm <=row; clm++)
                      {
                              printf("%c",'*');
                             
                      }

              //going to new line//
              printf("\n");
      }
getche();
return 0;
}