Monday, June 27, 2022

Odd and Even Number Using Function in C

 A simple program that I wrote to ask the user to give any number and then the program will check if the given number is an odd and even number using functions and bitwise operator in C programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

=================================================


Want to support my channel?

GCash Account

Jake Pomperada

09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support.





Program Listing

/* odd_even_number.c

Jake Rodriguez Pomperada, MAED-IT, MIT

www.jakerpomperada.com and www.jakerpomperada@gmail.com

jakerpomperada@gmail.com

Bacolod City, Negros Occidental

*/


#include <stdio.h>



/**

 * Function to check even or odd

 * Returns 1 is num is even otherwise 0

 * if odd number. Using bitwise operator

*  in a function to check for odd and even

*  numbers

 */

int isEven_Number(int num)

{

    return !(num & 1);

}



int main()

{

    int val_num=0;

    

    

    printf("\n\n");

    printf("\tOdd and Even Number Using Function in C\n");

    printf("\n");

    printf("\tGive any number: ");

    scanf("%d", &val_num);

    

    

    printf("\n\n");


      if(isEven_Number(val_num))

    {

        printf("\tThe given number %d is even number.",val_num);

    }

    else

    {

         printf("\tThe given number %d is odd number.",val_num);

    }

    printf("\n\n");

    printf("\tEnd of Program");

    printf("\n");

    return 0;

    

}



No comments:

Post a Comment