Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

describe the main employment rights as stated in the law

Answered: 1 week ago