#include<iostream>
using namespace std;
int main()
{
int a,rem,rev=0;
cout << "Enter the value for a:";
cin >> a;
while (a!=0)
{
rem = a % 10;
rev = rev * 10 + rem;
a = a / 10;
}
if (rev % 2 == 0)
cout << "It is even";
else
cout << "It is odd";
getchar();
getchar();
return 0;
}
//(with easy way)
#include<iostream>
using namespace std;
int main()
{
int a,rem,q=0;
cout << "Enter the value for a:";
cin >> a;
q = a / 10;
if (q % 2 == 0)
cout << "It is even";
else
cout << "It is odd";
getchar();
getchar();
return 0;
}
Comments
Post a Comment