Wednesday, 5 October 2011

Patterns in C language



/* Pattern 6:


1 2 3 4 5
   2 3 4 5
      3 4 5
         4 5
           5           */






#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,s=0;
clrscr();
printf(" \n\nPattern 6:\n\n");
for(x=1;x<=5;x++)
{
  s=0;
     do
     {
      printf(" ");
      s++;
      }while(s<x);
  for(y=x;y<=5;y++)
     {
      printf("%d",y);
      }
 printf("\n");
 }
getch();
}






/* Now print the following pattern for your own practice.....


        1
      21
    321
  4321
54321     easy code .....*/

No comments:

Post a Comment