192k views
1 vote
Write an application that asks a user to enter an integer. Display a statement that indicates whether the integer is even or odd.

User Jnovacho
by
4.8k points

1 Answer

5 votes

Answer:

in C++:

#include <iostream>

int main(){

int input;

std::cout<<"Enter a number: "<<std::endl;

std::cin>>input;

if(input%2==0){

std::cout<<" The number is even"<<std::endl;

}else{

std::cout<<"The number is odd"<<std::endl;

}

}

Step-by-step explanation:

Getting user input as integer, and check if NUMBER÷2 have remainder=0 or no, if remainder==0 then number is even else number is odd

User Dirk Horsten
by
5.1k points