Chinese, asked by yugggggg, 1 year ago

write a program to find whether the number is even or odd

Answers

Answered by Ronnyxxxx
5
/*

 * C++ program to check if given integer is even or odd

 */

#include<iostream>

using namespace std;

 

int main()

{

int number, remainder;

 

cout << "Enter the number : ";

cin >> number;

remainder = number % 2;

if (remainder == 0)

cout << number << " is an even integer " << endl;

else

cout << number << " is an odd integer " << endl;

 

return 0;

}

Answered by natassha
1

Since you didn't mention the programming language I'm writing in c programming language.



#include<iostream.h>

#include<stdio.h>

int main()

{

int n;

printf("Enter an integer\n");

scanf("%d", &n);

if (n%2 == 0)

printf("Even\n");

else

printf("Odd\n");

return 0;

}

Similar questions