Monday, October 10, 2011

Odd Numbers Being Looped(Iterative)


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

(Solution)

#include<stdio.h>

#include<conio.h>
#define s scanf
#define p printf
int main( )
{
          int M, N, O;

          p("Enter number amount of odd: ");
          s("%d", &N);
          
          for(M=1; M<=N; M++)
          {
                  O = M + M - 1;
                  p("%d\n", O);
           }
getch( );
}

1 comments:

RAGNEGAR said...
This comment has been removed by the author.

Post a Comment