C Programming question write a function named even that tak
C Programming question:
write a function named even () that takes an integer as a parameter and returns 1 if the integer is even and 0 if the integer is not even. write a program that prompts for and accepts input of an integer, calls your function with the input value as an argument and then displays either \"even\" or \"odd\" depending on the return value of the function.
Solution
#include <stdio.h>
 int even(int num);
 //declaring main method
 int main()
 {
 int number,result;
printf(\"Enter an integer: \");
 scanf(\"%d\", &number);
    //calling the function even to calculate if the number is even or odd and storing the output in variable result
 result = even(number);
 // True if the number is perfectly divisible by 2
 if(result == 0)
 printf(\"%d is even.\", number);
 else
 printf(\"%d is odd.\", number);
return 0;
 }
 // function to calculae if the number is even or odd
 int even(int num)
 {
 if(num % 2 == 0)
 return(1);
 else
 return(0);
 }

