Header Ads Widget

C++ program to check whether a number is even or odd

 

  C++ program to check whether a number is even or odd

Given a number , write a program to check whether number is even or odd .

Sample input 

8

Sample output

8 is even

C++ program to check whether a number is even or odd

The objective of the code is check whether number is even or odd .

Code(C++):-

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin>>a;
  if(a%2==0)
   cout<<a<<" is even";
  else
   cout<<a<<" is odd";
}

Output:-

8
8 is even

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

Post a Comment

0 Comments