+ 1

Can anyone help me

Write a program that inputs a series of integers and passes them one at a time to function bool isEven(int a), that determine whether an integer is even. The function should take an integer argument and return true if the integer is even and false otherwise.

2nd Sep 2022, 10:03 PM
Ammar ALfalahi
4 Answers
+ 1
the following is the code: int even(int value) { if(value % 2 == 0){ cout<<"the value is even:"<<value; } main(){ even(12);
3rd Sep 2022, 4:08 AM
Ahmad Zubair Afghanmal
+ 3
i'd recommend not to check the oddity by %2 but to use bitwise operator & it is faster and closer to assembly language it would look like: return !(a & 1); returns 0 (!1) if last bit is 1 - not even or 1 (!0) if last bit is 0 - even
3rd Sep 2022, 1:13 AM
Patrick
Patrick - avatar
+ 2
by using integer%2==0ļ¼Œtrue if even.
2nd Sep 2022, 10:36 PM
abpatrick catkilltsoi
abpatrick catkilltsoi - avatar
0
In array
2nd Sep 2022, 10:03 PM
Ammar ALfalahi