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

What are the chances of getting struck by lightning?
What two perfect squares is the number 70 between
Someone please help me with this. I'm absolutely horrible at government.
How to tell your salaried employees they are now hourly?
What causes a nova explosion
Why is it unlikely that two contour lines will cross?
Each year, field workers travel from the southwestern United States to eastern Washington to harvest apples
Solve x^2-2(x-3) when x = 3
a cookie factory uses 1/10 of a bag of flour in each batch of cookies. the factory used 1/2 of a bag of flour yesterday. how many batches of cookies did the fac
How did the Patriots get their name?