Write a program in C++ to input a number and check whether it is even or odd. Write down sample output also for your program. in Dev c++
Answers
Answered by
2
Answer:
#include<iostream>
using namespace std;
int main(){
int num;
cout << "Enter a number: ";
cin >> num;
if(num % 2 == 0) {
cout << "It is a even number.";
} else {
cout << "It is a odd number.";
}
}
I don't have dev C++ so I used VS Code. Codes of C++ is same.
Attachments:

Answered by
1
- Write a program in C++ to input a number and check whether it is even or odd.
#include <iostream.h>
using namespace std;
int main()
{
int n=0;
cout << "Enter a number: ";
cin >> n
if(n%2==0)
cout << "Number is Even. ";
else
cout << "Number is Odd. ";
return 0;
}
Enter a number: 59
Number is Odd.
Attachments:

Similar questions