Wednesday, April 3, 2013

C Language Example # 50 Series Example # 02 Display Odd numbers Series

C Language Example # 50 Series Example # 02 Display Odd numbers Series.

* This program is example of simple odd number series and even number series.

//Written by : Latest Technology Guide
//Title : C Language Example # 50 Series Example # 02 Display Odd numbers Series.

 
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int sum=1,n,i;

printf("Enter Number of Terms :");
scanf("%d",&n);

printf("\n\n ****** 1st Method  **********\n\n");
for(i=1;i<=n;i=i+2)
{
printf(" %3d ",i);
}
printf("\n\n ****** 2nd Method  **********\n\n");
for(i=1;i<=n;i++)
{
    sum = sum + 2;
    printf(" %3d ",sum);
}


getch();
}
Output:




--------------------------------------------------------------------------------
Explanation of C Programming Language Example # 50 Series Example # 02 Display Odd numbers Series.

*  Program will display odd number series.


Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements.

1 comment: