Write a Program to check whether a number is even or odd. Given an input number, we have to write a code to check whether an input number is even or odd.

Before solving this problem, let's first understand what is even or odd number?

Any integer that can be perfectly divisible by 2 is an even number.

For example - 2, 4, 6, 8, 10 etc.

Program to print sum of first ten numbers

Program to count number of vowels in a string

2. Take an input number from user and store this value in num variable.

C program to print even numbers between 1 to 100 using for and while loop

10 is an even number

Find sum of first n odd numbers in C, C++

Programming question on Arrays

Programming question on Linked List

Sorting algorithm and their time complexity

Stack implementation

Programming questions using Recursion

C, C++ interview questions

Programming Books

C, C++ interview questions for practice

Before solving this problem, let's first understand what is even or odd number?

#### Even number

For example - 2, 4, 6, 8, 10 etc.

#### Odd Number

An odd number is a number that is not divisible by 2.

For example - 3, 5, 7 etc.

Program to print sum of first ten numbers

Program to count number of vowels in a string

**Algorithm to check whether a number is even or odd number****1. Declare a variable num (You can declare any variable).**

2. Take an input number from user and store this value in num variable.

**3. Check whether a number is perfectly divisible by 2 .If it is divisible by 2 then it's a even number otherwise it is an odd number.**

C program to print even numbers between 1 to 100 using for and while loop

## C Program to Check whether a Number is Even or Odd

#include <stdio.h> void main() { int num; printf("Enter an integer value"); scanf("%d", &num); /* If a number is perfectly divisible by 2 then it's an even number*/ if(num % 2 == 0){ printf(" \n %d is an even number ", num); } else { printf(" \n %d is an odd number ", num); } }

**Output :****Enter an integer value : 10**

10 is an even number

Find sum of first n odd numbers in C, C++

## C++ Program to Check whether a Number is Even or Odd

#include <iostream> using namespace std; int main() { int num; cout << "Enter an integer value\n"; cin >> num; if(num % 2 == 0){ cout << " \n Entered number is an even number "; } else { cout << " \n Entered number is an odd number "; } return 0; }

Programming question on Arrays

Programming question on Linked List

Sorting algorithm and their time complexity

Stack implementation

Programming questions using Recursion

C, C++ interview questions

Programming Books

C, C++ interview questions for practice

## No comments:

## Post a Comment