Syvum Home Page

Home > Quiz Games > C++ Programming > Print Preview

C++ Programming : Program 22-A

Program to enter an integer and find out if it is even or odd


 

#include <iostream.h>
#include <conio.h>

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.

86

The number 86 is even.

Index of C++ Programs
 

-
-
 
45 more pages in C++ Programming

Contact Info © 1999-2024 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright