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).
To debug a code, means that we locate and fix the errors in a code.
The issue with your code is that:
<em>You did not convert num_owls_A and num_owls_B to integers, when adding them together.</em>
The fix to this is that:
<em>You need to convert num_owls_A and num_owls_B to integers, when adding them together.</em>
The fix is as follows:
<em>total_owls = int(num_owls_A) + int(num_owls_B)</em>
The updated code is as follows:
<em>total_owls = 0
</em>
<em>num_owls_A = input()
</em>
<em>num_owls_B = input()
</em>
<em>total_owls = int(num_owls_A) + int(num_owls_B)
</em>
<em>print('Number of owls:', total_owls)</em>
<em />
<em>The above code will perform addition operations for all inputs</em>
Read more about Python programs at:
brainly.com/question/13246781
Explanation: torsearch.org is a safe search engine mainly used for dark wed purposes. It does not track your location nor give any personal information.
<span><span><span /></span></span>Both Technicians
(A and B) are correct since the aluminum cylinder head surfaces should be
scraped clean only with nonmetallic tools to avoid gouging and it should also
be chemically cleaned in accordance with the manufacturer's recommendations
before the inspection.<span><span /></span>
The three different types of hard drives are:
<h3>What is the SATA drive?</h3>
This was said to be Introduced in the year 2003, SATA (or Serial Advanced Technology Attachment) is known to be a kind of a default interface that was made for a lot of desktop and laptop hard drives.
Hence, The three different types of hard drives are:
Learn more about hard drives from
brainly.com/question/1558359
#SPJ1