Feb 27, 2007

C++ program to find odd numbers between 1 to 100

C++ program to find odd numbers between 1 to 100
// In this C++ program the for loop is generating a number from 1 to 100
// and increment by 1. In loop the program will check each number whether
// it is odd or not by taking a%2!=0. If result of a mod 2 is not equals to 0
// means number is odd and it will get printed by cout statement
#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int a;
for (a=1;a<=100;a++)
{
if (a%2!=0)
{
cout << a <<endl;
}
}
getch();
}

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive