scotrebe225 scotrebe225
  • 04-07-2019
  • Computers and Technology
contestada

Write a function which accepts an integer and returns true if the number is odd or false if the number is even

Respuesta :

SerenaBochenek SerenaBochenek
  • 12-07-2019

Answer:

#include<stdio.h>

#include<stdbool.h>

bool isEven(int x);

main()

{

int n;

bool v;

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

scanf("%d", &n);

v = isEven(n);

if(v==true)

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

else

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

}

bool isEven(int x)

{

if(x%2==0)

 return true;

else

 return false;

}

Explanation:

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

else the integer is odd.

Ver imagen SerenaBochenek
Answer Link

Otras preguntas

The width of a computer monitor is 30 cm. If the perimeter is 144 cm, what is the area of the computer monitor?
A soccer team played 160 games and won 65 percent of them. How many games did it win ?
Is There Still Slavery in the World? Please help me :)
How do you solve p+9 <7 AND graph it???
please help :-( thanks
Did Maya Angelou's uncle kill the mom's boyfriend after finding out he raped Maya or beat him to death?
A uniform wire is cut into 4 segments. Each segment is twice as long as the earlier segment. If the shortest segment has a resistance of 4 ohm, find the resista
what are at least 5 general PowerPoint guidelines that's you find useful and provide an example of how you would use each in real life setting
please help :-( thanks
Is Smoking in Japan Illegal? Please help me :)