Write a programe that inputs a series of integers and passes them ONE AT A TIME TO A FUNCTION 'EVEN' which uses the modulus operator to determine IF AN INTEGER IS EVEN THE FUNCTION SHOULD TAKE TWO INTEGER ARGUMENTS AND return true if the integer is even else return false.....
I can't understand this question...
I don't see why the function would take two integer arguments.
If you are required to test whether the number is odd or even, it needs just one argument, and a boolean return type.
It doesn't specify a whole lot, but you do need a function that will check if an integer is even:
1 2 3 4 5
bool is_even(int x)
{
if (x%2) returnfalse;
elsereturntrue;
}
You also need to input a series of integers:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
int integers[10];
// input integers
for (int i = 0; i < 10; ++i)
cin >> integers[i];
// test each integer and do something
for (int i = 0; i < 10; ++i)
if ( is_even(integers[i]) )
cout << integers[i] << " is even\n";
return 0;
}
I think the qusetion is not true....my teacher give me a assignment of 24 question and i was worry about this wrong question......once we pas an integer then the function again take two integers how its possible.....
Thanks for help...
You could use one of the arguments as an output instead of using a return type. The fact that it is an int instead of bool simply tells us that we are working in C instead of C++. It could be something like this I guess: