C++ Program to check the number is Even or Odd:Numbers perfectly divisible by 2 are known even numbers and numbers which are not divisible by 2 are called odd numbers.This program takes an integer from user and checks whether that number is even or odd and displays the result.In this program, user is asked to enter an integer which is stored in variable a.
Then, the remainder is found when that number is divided by 2 and
checked whether remainder is 0 or not.
If remainder is 0 then, that
number is even otherwise that number is odd. This task is performed
using if...else statement in C programming and the result is displayed accordingly.
Source Code:-
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int a;
cout<<"Check Number is Even or Odd by-Tarun Rawar\n";
cout<<"\nEnter number to check : ";
cin>>a;
if(a%2==0)
cout<<"\n"<<a<<" is a Even number ";
else cout<<"\n"<<a<<" is a Odd number ";
getch();
}
Welcome to " way2cplusplus.blogspot.in " Objective of this blog is to implement various Computer Science Engineering Lab problems into C++ programming language. These are basically most common Lab Exercise problems based on the curriculum of engineering colleges throughout the Nation. These lab exercises are also relevant to Data structure. Simply C++ programming zone...
No comments:
Post a Comment