Advertisement

If limit =5. Then…… 1 3 5 5 9…………


#include<conio.h>
#include<stdio.h>
void main()

      {    clrscr();
                   int i,n,a=1,b=3;
                   scanf("%d",&n);
                   for(i=1;i<=n;i++)
                   {
                                if(i%2==0)
                     {  printf("%d ",b);
                                b=b+2;
                                }
                                else
                                {  printf("%d ",a);
                                   a=a+4;
                                   }
                                   }
                                   getch();
                                                  }

No comments:

Post a Comment

Please comment bellow. Share your knowledge