BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/300-object-oriented-programming/)
-   -   Program to enter an integer and find out if it is even or odd (http://bzupages.com/f300/program-enter-integer-find-out-if-even-odd-14571/)

bonfire 01-03-2011 03:08 PM

Program to enter an integer and find out if it is even or odd
 
1 Attachment(s)
Program to enter an integer and find out if it is even or odd


#include
#include

void main()
{
clrscr();
int x;
cout << "Enter an integer : ";
cin>>x;
if(x%2==0)
cout << "The number " << x << " is even.";
else
cout << "The number " << x << " is odd.";
getch();
}
This program takes in an integer x as a screen input from the user.
It then determines whether the integer is odd or even and outputs the appropriate message using the 'cout' command.

Sample Input86
Sample Output
The number 86 is even.


All times are GMT +5. The time now is 07:52 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.