Answer:
blank 4
Explanation:
I just did this assignment got 100
Answer:
The program to this question as follows:
Program:
def isEvenPositiveInt(x): #defining method isEvenPositiveInt
if x>0: #checking number is positive or not
if x%2==0: #check true condition
return True #return value True
else:
return False #return value False
return False #return value False
print(isEvenPositiveInt(24)) #calling method and print return value
print(isEvenPositiveInt(-24)) #calling method and print return value
print(isEvenPositiveInt(23)) #calling method and print return value
Output:
True
False
False
Explanation:
In the above Python program, a method "isEvenPositiveInt" is defined, that accepts a variable "x" as its parameter, inside the method a conditional statement is used, which can be described as follows:
- In the if block the condition "x>0" is passed, that check value is positive, if this condition is true, it will go to another if block.
- In another, if block is defined, that checks the inserted value is even or not, if the value is even it will return "true", otherwise it will go to the else part, that returns "false".
Answer:
The solution code is written in C
- #include <stdio.h>
- int main()
- {
- const int NUM_VALS = 4;
- int courseGrades[NUM_VALS];
- int i;
-
- for (i = 0; i < NUM_VALS; ++i) {
- scanf("%d", &(courseGrades[i]));
- }
-
- /* Your solution goes here */
- for(i = 0; i < NUM_VALS; ++i){
- printf("%d ", courseGrades[i]);
- }
- printf("\n");
-
- for(i = NUM_VALS - 1; i >=0; --i){
- printf("%d ", courseGrades[i]);
- }
- printf("\n");
-
- return 0;
- }
Explanation:
The solution is highlighted in the bold font.
To print the elements forward, create a for loop to start the iteration with i = 0 (Line 14). This will enable the program to get the first element and print if out followed with a space (Line 15). The program will take the second element in the next iteration.
To print the elements backward, create a for loop to start the iteration with i = NUM_VALS - 1. The NUM_VALS - 1 will give the last index of the array and therefore the loop will start printing the last element, followed the second last and so on (Line 19 - 21).