Skip to main content

C Program to Check Even or Odd Without Modulous and Bitwise Operator

 

C Program to Check Even or Odd Without Modulous and Bitwise Operator

 

                In this example we will check even or odd without Modulous Operator. To do this program we should know what is even and odd number.

 

                Even Number: Even numbers are those numbers which are divisible by 2. That means if we divide a number by 2 and if its remainder appears 0 then it is an even number.

                                For Example: 2,4,6,8,10,12,.... are all even numbers.

                               

                Odd Number: Odd numbers are those numbers which are not divisible by 2. That means if we divide a number by 2 and if its remainder appears 1 then it an odd number.

                                For Example: 1,3,5,7,9,11,........ are all odd numbers.

                               

                               

Program:


#include<stdio.h>
#include<conio.h>
int main()
{
    int x;
    printf("\nEnter two numbers : ");
    scanf("%d",&x);
    if(x/2*2==x)
        printf("\n%d is an Even number\n",x);
    else
        printf("\n%d id an Odd number\n",x);
    return 0;
}


Output:

  

C Program to Check Even or Odd Without Modulous and Bitwise Operator

 

C Program to Check Even or Odd Number using Modulous Operator.

 

 

Program:


#include<stdio.h>
#include<conio.h>
int main()
{
    int x;
    printf("\nEnter two numbers : ");
    scanf("%d",&x);
    if(x%2==0)
        printf("\n%d is an Even number\n",x);
    else
        printf("\n%d id an Odd number\n",x);
    return 0;
}

Output:

 

C Program to Check Even or Odd Number using Modulous Operator.





NOTE: You Can Comment Your Code if you have solved differently and we will pin it in the comment section.  Let's Learn together. 


MOTTO: 

You Learn, I Learn together We Learn.

Comments

Popular posts from this blog

C Program to Calculate the Factorial of a number using Function

  C Program to Calculate the Factorial of a number using Function.     In this example, we will calculate the factorial of a number using function. Here we have used functions with Arguments and return value to perform this operation. We have declared a user-defined function fact which is called in the main function when printing the result. What is a Factorial of  a Number?      The factorial of a number is the product of all positive integers less than, equal to n. Factorial is denoted by the symbol '!'. Formula of factorial is n!=n x (n-1)! For example: 6!= 6 x 5 x 4 x 3 x 2 x1    = 720 PROGRAM TO CALCULATE THE FACTORIAL OF A NUMBER USING FUNCTION #include <stdio.h> #include <conio.h> int   fact ( int ); void   main () {      int   n ;      printf ( "Enter the number : " );      scanf ( " %d " ,& n );   ...

C program to calculate area of a circle using function.

C program to calculate area of a circle. In this example we will learn to calculate the area of a circle. Here in this program we will use 3.14 as the value of pi.  The formula to calculate the area of a circle is:                                                         area=   π  r² Flowchart To Calculate the Area of a Circle: PROGRAM: #include <conio.h> #include <stdio.h> int   main () {      float   radius , area ;      printf ( "Enter the radius of the circle : " );      scanf ( "%f" ,& radius );      area = 3.14 * radius * radius ;          printf ( "Area of the circle is : %.2f" , area );  ...

C Program to find the sum of the series 1^2+2^2+3^2+…..+n^2

C Program to find the sum of the series  1 2 +2 2 +3 2 +…..+n 2 Enter the end limit at the runtime.       In this example, we calculate the sum of the above mentioned series till the end-limit entered by the user. We have used built-in function pow(x,y) to find the power of the given number.     Here in the output we have entered the value of end-limit as number 7 which gives a sum of 140.    PROGRAM #include <stdio.h> #include <math.h> #include <conio.h> void   main () {      int  n,sum= 0 ,i;      printf ( "Enter the end limit :" );      scanf ( " %d " ,&n);      for (i= 1 ;i<=n;i++)     {         sum=sum+ pow (i, 2 );     }      printf ( "Sum of the series is :  %d " ,sum);  ...

C Program to input Values in a 2x2 square matrix and display the value

 C Program to input Values in a 2x2 square matrix and display the value     In this example, we will accept values from the user in a 2x2 square and matrix and then it is displayed. To solve this problem we must know what is matrices and arrays. What are Arrays?      An array is a data structure for storing more than one data member of similar data type.          Array can be of following types: One-dimensional Array Two-dimensional Array Multi-dimensional Array             In Array we must always initialize values. PROGRAM #include <stdio.h> #include <conio.h> int   main () {      int   a [ 2 ][ 2 ], i , j ;      printf ( "Enter the values of the matrix:" );      for ( i = 0 ; i < 2 ; i ++)     {          for ( j = 0 ; j < 2 ...

C Program to find the sum of the elements of a 2-D array.

 C Program to find the sum of the elements of a 2-D array.     In this example, we will find the sum of the elements of a 2-D array allowing the user to enter the row size and column size according to their requiremnts.      Here in the output we have entered a row  size 3 and column size 3. PROGRAM #include <stdio.h> #include <conio.h> void   main () {      int   a [ 50 ][ 50 ], r , c , i , j , sum = 0 ;      printf ( "Enter the row size and column size of the array :" );      scanf ( " %d%d " ,& r ,& c );      printf ( "Enter the elements of the array : " );      for ( i = 0 ; i < r ; i ++)     {          for ( j = 0 ; j < c ; j ++)       ...