478,333 views
27 votes
27 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 Zhenguoli
by
2.6k points

2 Answers

9 votes
9 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 Yasitha Bandara
by
3.3k points
8 votes
8 votes

#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;

}

User Gianni Di Noia
by
3.1k points