Sunday, October 16, 2011

Write a program that asks the user to enter a number n and display the first n odd numbers. Example: if n=5, the first 5 odd numbers are 1, 3, 5, 7 and 9.

     #include<stdio.h>
     #include<conio.h>
     #define p printf
     #define s scanf


     int main()
     {
         int m, j;
   
         p("Enter number: ");
         s("%d",&j);
   
              for (m=1;m<=j*2;m+=2)
                 {
                 p("%d\n",m);
                 }

         getch ();
         return 0;
     }

No comments:

Post a Comment