Author Topic: Turbo C Program for displaying pattern of Coke using Star  (Read 1986 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Turbo C Program for displaying pattern of Coke using Star
« on: February 21, 2012, 12:33:11 pm »
Here is the Turbo C Program for displaying pattern of Coke using Star.



Code:
//Source Code Listing


#include <stdio.h>
#include <string.h>

int main() 
{ 
   static int pattern[] = { 3, 3, 5, 7, 7, 7, 5, 5, 7, 7, 7, 5 };
   int i = 0, j = 0; 
   printf("Program for displaying pattern of Coke Star\n\n"); 
   
   for(i = 0; i < sizeof(pattern) / sizeof(pattern[0]); i++) 
   { 
      printf("%10s", " ");
      if(i < 2)
         printf("%3s", " ");
      else if(i < 3)
         printf("%2s", " ");
      else if(i < 6)
         printf("%1s", " ");
      else if(i < 8)
         printf("%2s", " ");
      else if(i < 11)
         printf("%1s", " ");
      else 
         printf("%2s", " ");

      for(j = 0; j < pattern[i]; j++) 
      { 
         printf("*");
      } 

      printf("\n");
   } 

   getch();

   return 0; 
}


 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1