Answer:
- #include <stdio.h>
-
- bool IsArrayEven(int inputVals[], int numVals){
- int i;
- for(i = 1; i < numVals; i++){
- if(inputVals[i] % 2 != 0){
- return false;
- }
- }
- return true;
- }
-
- bool IsArrayOdd(int inputVals[], int numVals){
- int i;
- for(i = 1; i < numVals; i++){
- if(inputVals[i] % 2 == 0){
- return false;
- }
- }
- return true;
- }
-
- int main()
- {
- int my_input[] = {5, 2, 4, 6, 8, 10};
-
- if(IsArrayEven(my_input)){
- printf("all even");
- }else if(IsArrayOdd(my_input)){
- printf("all odd");
- }else{
- print("not even or odd");
- }
- }
Explanation:
Firstly, write two functions to check if the input array is all even or all odd (Line 3-22). The key idea is to use modulus operator to check if a number % 2 equal to 0, it is an even number, if not, it is an odd. So long as one of the number is odd in the isArrayEven function, the function shall return false (Line 7). If no odd value detected, it return true (Line 11). The similar code logic is applied to isArrayOdd function too.
Then, we can call the two functions sequentially in the main program. If isArrayEven function return true, it display all even message (Line 28-29). If odd, display all odd (Line 30 -31). If neither, display not even or odd (Line 32-33).
Answer: what do you need help with?
Explanation:
Answer:
The United Arab Emirates consists of seven independent city-states: Abu Dhabi, Dubai, Sharjah, Umm al-Qaiwain, Fujairah, Ajman and Ra's al-Khaimah.
Explanation:
I hope this will help you
Answer:
d. Emperor penguin family or b. Penguin colony