Program to check first digit between two digits that is it odd or even number

 #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

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........