Friday 25 July 2014

C++ Check Whether entered numbers are even or not

Purpose of the program is basically understanding that the entered various amount of numbers by user and test whether all of them are verifies that they are even number or not and how we check each number by using loop , what is the purpose to use loop why i use it ? efficient + reliable and deep understanding of concept make it possible to do efficient and complex less logic to easily understand program



Hope You will enjoy to do programming ....!

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



int main()
{
int num1,num2,num3,num4;

for(int i=0;i<4;i++)
{
cout<<"Please Enter the number = "<<i<<" = ";
if(i==0){cin>>num1;}
else if(i==1){cin>>num2;}
else if(i==2){cin>>num3;}
else cin>>num4;
}

//cout<<"You have Entered the numbers are as under \n "<<num1<<"\n then = "<<num2<<"\n then = "<<num3<<"\n then ="<<num4<<endl;

cout<<"\n\t----Results-----";
cout<<"\n\t----Even or Odd-----";
cout<<"\n\n";
int i=0;
while(i<4)
{
if(i==0)
{
if(num1%2 == 0){ cout<<"Entered First number is even = "<<num1<<endl;}
else
cout<<"Entered First number is not even = "<<num1<<endl;
}

if(i==1)
{
if(num2%2 == 0){ cout<<"Entered second number is even = "<<num2<<endl;}
else
cout<<"Entered second number is not even = "<<num2<<endl;
}
if(i==2)
{
if(num3%2 == 0){ cout<<"Entered third number is even = "<<num3<<endl;}
else
cout<<"Entered third number is not even = "<<num3<<endl;
}
if(i==3)
{
if(num4%2 == 0){ cout<<"Entered Fourth number is even = "<<num4<<endl;}
else
cout<<"Entered Fourth number is not even = "<<num4<<endl;
}
i++;
}


getch();
return 0;
}