Adsense 728 * 15

Search

Custom Search

C, C++ Program to Check Whether a Number is Even or Odd

C, C++ Program to Check Whether a Number is Even or Odd
C, C++ Program to Check Whether a Number is Even or Odd
Write C,C++ Program to check whether a input number is even or odd. In this program, a number is input by a user and our program will check whether a input number is even or odd.

Program to print sum of first ten numbers

Program to count number of vowels in a string


Algorithm to check even or odd number

1. Declare a variable num (You can declare any variable).


2. Take a input 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 Check whether a Input Number is Even or Odd


#include <stdio.h>

void main()
{
 
   int num; 
 
   printf("Enter an integer value");
   scanf("%d", &num);
 
   /* If number is perfectly
      divisible by 2 */

   if(num%2 == 0){  
      printf(" \n Entered number is an even number ");
   } else {
      printf(" \n Entered number is an odd number ");
   }

}



Output :

Enter an integer value  : 10

Entered number is an even number


C++ Program to Check whether a Input 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