Write a C C++ program to check odd or even number

 

Flowchart

Checking whether given number is even or odd flowchart

 

Coding in C

#include<stdio.h>
int main()
{
int n;
printf(“Enter a number: “);
scanf(“%d”,&n);
if(n%2==0)
{
printf(“Even number”);
}
else
{
printf(“Odd number”);
}
return 0;
}

 

Coding in C++

#include<iostream>
using namespace std;
int main()
{
int n;
cout<<“Enter a number: “;
cin>>n;
if(n%2==0)
{
cout<<“Even number”;
}
else
{
cout<<“Odd number”;
}
return 0;
}

 

Output

Checking whether given number is even or odd output

 

Published by

admin

I am a computer teacher, programmer and web developer