107k views
3 votes
Write a function which accepts an integer and returns true if the number is odd or false if the number is even

User Mmond
by
6.0k points

1 Answer

1 vote

Answer:

#include<stdio.h>

#include<stdbool.h>

bool isEven(int x);

main()

{

int n;

bool v;

printf("Enter an integer: \\");

scanf("%d", &n);

v = isEven(n);

if(v==true)

printf("\\ The integer is even");

else

printf("\\ The integer is odd");

}

bool isEven(int x)

{

if(x%2==0)

return true;

else

return false;

}

Step-by-step explanation:

if the integer is divided by 2 then the integer is even

else the integer is odd.

Write a function which accepts an integer and returns true if the number is odd or-example-1
User Miles Fett
by
6.9k points