Checks whether the Number is even or odd. Using if-else
Object: Write a program that takes a number and checks whether the Number is even or odd. Using if-else. C++ Projects
Code:
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int num1;
cout<<” Enter Any Number: “;
cin>>num1;
if(num1%2==0)
{
cout<<“\n Given Number is Even.”;
}
else
{
cout<<“\n Given Number is Odd.”;
}
getch();
}
#include<iostream> #include<conio.h> using namespace std; void main() { int num1; cout<<" Enter Any Number: "; cin>>num1; if(num1%2==0) { cout<<"\n Given Number is Even."; } else { cout<<"\n Given Number is Odd."; } getch(); }