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

by Nideesh C on February 8, 2011 · 0 comments

in C++




#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.

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Sample – Program to enter an integer and output the cube of that integer.
  2. Sample – Program to enter an integer and print out its successor.
  3. Sample – Program to enter a string and find its length.
  4. Sample – Program to enter two integers and print the quotient and remainder.
  5. Sample – functions

Leave a Comment

Previous post:

Next post: