Saturday, July 20, 2013

Number Pattern in C

Pattern-01
1
2 6                    
3 7 10 
4 8 11 13 
5 9 12 14 15

#include<stdio.h>
main()
{
  int i,j,k;
  for(i=1;i<=5;i++)
  {
    k = i;
    for(j=1;j<=i;j++)
    {
      printf("%d ",k);
      k += 5-j;
    }
    printf("\n");
  }
}


No comments:

Post a Comment