recent

program to print given number pattern

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

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