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

Why was there fear of communism and communist subversion after WWII
Determine the number of possible triangles, ABC, that can be formed given angle A = 30°, a = 4, and b = 6.
During the Clinton Administration, welfare programs were
How to find the area of a regular polygon
What is the third term of the sequence? a1 = m an = 2an-1
David’s mother is killed in an automobile accident. What type of insurance would provide his family financial support to cover the paid and unpaid work his moth
What are the colors of the bisexual flag?
what is an example of scarcity
To _______ means to combine two groups in such a way that one becomes fully part of the other.
Jarod used to think that all vegetables were green. Then one day, he had some beets, which are red. This led to an adjustment in an existing schema, in the proc