4.2k views
2 votes
Define a function called isEvenOdd(n) that accepts a number n as input argument and returns whether the number is even or odd. Call your functions

User DSander
by
2.9k points

2 Answers

3 votes

Answer:

Step-by-step explanation:

var n : integer;

function IsEvenOdd (n : integer): boolean;

begin

if odd (n) then Result := true

else Result := false;

end;

begin

Write (' n = '); ReadLn (n);

WriteLn (' ', IsEvenOdd (n));

end.

User Twan Van Laarhoven
by
3.4k points
1 vote

#include <bits/stdc++.h>

typedef std::string s;

s isEvenOdd(int n) {

return (n%2==0) ? "Even" : "Odd";

}

int main(int argc, char* argv[]) {

int x; std::cin>>x;

std::cout << isEvenOdd(x) << std::endl;

return 0;

}