recent

c program to print given number pattern

Write a c program to print given number pattern 
     1
  2 3 4
5 6 7 8 9

#include<stdio.h>
int main()
{
  int i,m,n;
  n=1;
  for(i=1;i<=5;i+=2)
  {
    for(m=5;m>=1;m--)
    {
      if(m>i)
        printf(" ");
      else
        printf("%d ",n++);
    }
    printf("\n");
  }
}
Powered by Blogger.