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

A rectangular prism has a volume of 105 m3. This prism is enlarged using a scale factor of 4. What is the volume of the enlarged prism?Please Explain...
An atom of which element has the strongest attraction for electrons? A) Ba B) Cs C) O D) F
1. What are the next three terms in the sequence?-1 ,9 ,19 ,29 . . .A. 38, 37, 32B. 40, 51, 62C. 39, 49 , 59D. 38, 47, 562. What are the next three terms of the
Given the volume of a cube is 8 cubic meters, find the distance from any vertex to the center point inside the cube. (A) 1 m (B) √2 m (C) 2√2 m (D) 2√3 m (E) √3
If y^8 = 4 and y^7 = 3/x, what is the value of y in terms of x? (A) 4x/3 (B) 3x/4 (C) 4/x (D) x/4 (E) 12/x
factoring, x squared +x-6?
list the 6 characteristics of american economy and explain how they help the economy grow
How does a Retinal Scan Work?
what are vertically opposite angles
If 5x^2 - 15x = 0 and x ≠ 0, find the value of x. (A) -10 (B) -3 (C) 10 (D) 5 (E) 3