Skip to content

Odd Even using Functions #43

Description

@akashnagpal1123

/**

  • C program to check even or odd using functions
    */

#include <stdio.h>

/**

  • Function to check even or odd
  • Returns 1 is num is even otherwise 0
    */
    int isEven(int num)
    {
    return !(num & 1);
    }

int main()
{
int num;

/* Input number from user */
printf("Enter any number: ");
scanf("%d", &num);


/* If isEven() function returns 0 then the number is even */
if(isEven(num))
{
    printf("The number is even.");
}
else
{
    printf("The number is odd.");
}

return 0;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions