How to find Even and Odd numbers - C++ Programming
To find Even and Odd:
To find that whether the entered number is even or odd we uses the following programs
Program:
#include < iostream >
using namespace std;
int main()
{
int num;
cout << "Enter the number please" << endl;
cin >> num;
if (num % 2 == 0)
{
cout << "number is even" << endl;
}
else
{
cout << "Number is odd" << endl;
}
return 0;
}
Program:
#include < iostream >
using namespace std;
int main()
{
int num;
cout << "Enter the number please" << endl;
cin >> num;
if (num % 2 != 0)
{
cout << "number is odd" << endl;
}
else
{
cout << "Number is even" << endl;
}
return 0;
}
Comments
Post a Comment