This is what the output HAS to be below. Tester and class HAVE to be separate. C
ID: 3667207 • Letter: T
Question
This is what the output HAS to be below. Tester and class HAVE to be separate.
Combo is: 12 12 12
Current Number: 0
Enter number of ticks to turn to the right 0 - 40. Enter an invalid number to quit (negative, or >40).
28
Current Number: 12
Enter number of ticks to turn to the left 0 - 40. Enter an invalid number to quit (negative, or >40).
40
Current Number: 12
Enter number of ticks to turn to the right 0 - 40. Enter an invalid number to quit (negative, or >40).
40
You opened the lock!
Would you like to run simulation again? (Yes or No)
y
Please enter 3 values for the new combo lock: 12 13 14
Combo is: 12 13 14
Current Number: 0
Enter number of ticks to turn to the right 0 - 40. Enter an invalid number to quit (negative, or >40).
28
Current Number: 12
Enter number of ticks to turn to the left 0 - 40. Enter an invalid number to quit (negative, or >40).
1
Current Number: 13
Enter number of ticks to turn to the right 0 - 40. Enter an invalid number to quit (negative, or >40).
39
You opened the lock!
Would you like to run simulation again? (Yes or No)
y
Please enter 3 values for the new combo lock: 1 2 3
This is the class so far
This is the tester:
Explanation / Answer
* Sum the odd and even numbers, respectively, from 1 to a given upperbound. * Also compute the absolute difference. * (SumOddEven.c) */ #include // Needed to use IO functions int main() { int sumOdd = 0; // For accumulating odd numbers, init to 0 int sumEven = 0; // For accumulating even numbers, init to 0 int upperbound; // Sum from 1 to this upperbound int absDiff; // The absolute difference between the two sums // Prompt user for an upperbound printf("Enter the upperbound: "); scanf("%d", &upperbound); // Use %d to read an int // Use a while-loop to repeatedly add 1, 2, 3,..., to the upperbound int number = 1; while (number sumEven) { absDiff = sumOdd - sumEven; } else { absDiff = sumEven - sumOdd; } // Print the results printf("The sum of odd numbers is %d. ", sumOdd); printf("The sum of even numbers is %d. ", sumEven); printf("The absolute difference is %d. ", absDiff); return 0; }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.