Odd or Even in C++ - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Friday, June 12, 2020

Odd or Even in C++



C++ PROGRAM TO FIND WHETHER A NUMBER IS ODD OR EVEN


Sample Test Case    :    Enter a Number : 5

Sample Test Case    :    5 is an Odd Number


CODE

#include<stdio.h>
using namespace std;
int main()
{
    int num;
    cout<<"Enter a Number :";
    cin>>num;
    if(num%2==0)
    {
        cout<<num<<" is an Odd Number";
    }
    else
    {
        cout<<num<<" is an Even Number";
    }
    return 0;
}

No comments:

Post a Comment