Question
(Using C) As you write this program, complete each of the 5 steps below individually, and compile the program after each step. Your program should
(Using C)
As you write this program, complete each of the 5 steps below individually, and compile the program after each step.
Your program should do the following:
Declare 3 integers variables and a 100-element integer array - clear the contents of all memory locations (i.e. set each location to zero)
As you write the program you may need additional variables - declare these as necessary
Ask the user for two integers - assume that the first one they enter is smaller than the second (your prompts should direct them to enter the smaller integer first) - store these values in two of the integer variables
Ask the user for a third integer that will be used as a modulus - store this value in the third integer variable
Write a loop that will store all of the numbers between the smaller and larger number that are divisible by the modulus into the integer array (you can assume there will not be more than 100 of these numbers)
Write another loop that will calculate the sum of the numbers in the array
Print the smallest element in the array, the largest element in the array, and the sum of the numbers in the array
For example, if the user enters:
3 as the smaller integer
48 as the larger integer and
7 as the modulus
Then the program should print:
The smallest element is: 7
The largest element is: 42
The sum of the elements is: 147 (because the sequence 7, 14, 21, 28, 35, 42 represents all of the integers between 3 and 48 that are divisible by 7, - these numbers should all be stored in the array and the sum of these numbers is 147).
** At this point, test your program to make sure it runs correctly.
Once your program runs correctly, enhance your program so that the user does not have to enter the smaller number first. The program should determine which of the two integers is smaller.
** After making your enhancement, test your program to make sure it runs correctly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started