159k views
23 votes
How to write a code that determines if a number is odd or even?

the code should start with a variable declaration

User Panosru
by
5.9k points

1 Answer

6 votes

Answer:

//code in c++

#include <iostream>

using namespace std;

int main() {

int a;

cin>>a;

if(a%2==0){

cout<<"Even number";

}

else{

cout<<"Odd number";

}

return 0;

Step-by-step explanation:

User Haythem Souissi
by
6.5k points