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 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 ++)       ...

C Program to find the Transpose of a Matrix.

C Program to find the Transpose of  a Matrix.       In this example, we will find the transpose of a given matrix according to the requirements of the row size and column size.      Here in the output we have entered a 3x2 Matrix whose transpose will be 2x3 Matrix. PROGRAM #include <stdio.h> #include <conio.h> int   main () {      int   row , column , i , j , a [ 100 ][ 100 ];      printf ( "Enter the row size of the matrix :" );      scanf ( " %d " ,& row );      printf ( "Enter the column size of the matrix : " );      scanf ( " %d " ,& column );      printf ( "Enter the elements of the matrix : " );      for ( i = 0 ; i < row ; i ++)     {  ...

C Program to Swap the values of two variables using function.

C Program to Swap the values of two variables using function.     In this example, we swap the values of two variables using function. We have declared a function swap. PROGRAM #include <stdio.h> #include <conio.h> void   swap ( int *, int  *); int   main () {      int   a , b ;      printf ( "Enter the values of a and b : " );      scanf ( " %d%d " ,& a ,& b );      printf ( "Before swapping the values in main a= %d  , b= %d \n " , a , b );      swap (& a ,& b );      printf ( "After swapping the values in main a= %d  , b= %d \n " , a , b );      getch (); } void   swap ( int  * a , int  * b ) {      int   temp ;    ...

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 );   ...