Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and write a modular C program to perform the following tasks: USING FUNCT

ID: 3695137 • Letter: D

Question

Design and write a modular C program to perform the following tasks: USING FUNCTIONS FOR FINDING SUM, MINIMUM and MAXIMUM

1. ask the user for a positive number between 1 and 23, only accept those numbers

2. maintain a running sum of the numbers

3. continue asking for numbers while the sum of the numbers is less than 98

4. keep track of the largest & smallest number entered

5. when the sum of the numbers is more than 98 the program should stop asking for number input

6. display the sum of the numbers and the largest and smallest number entered

7. have the program continue running with new input until told to stop (allow for a new set of numbers to be entered)

Please do in C programming, not C++ or Java

Explanation / Answer

#include<stdio.h>

int main()
{
int i,sum,min,max;
min=25;;
max = -1;
sum=0;
while(1)
{
printf("Enter a number:");
scanf("%d",&i);
if(i<1 || i>23)
{
printf("Invalid input. Only enter numbers between 1 and 23 ");
continue;
}
sum +=i;
if(i<min)min=i;
if(i>max)max=i;
if(sum>98)
{
printf("The sum of the numbers is %d ",sum);
printf("The maximum value of the numbers is %d ",max);
printf("The minimum value of the numbers is %d ",min);
min=25;;
max = -1;
sum=0;
printf("Do you wish to enter the next set of numbers?(enter 1 to continue|any other number to exit):");
scanf("%d",&i);
if(i==1)
{
printf("Okay! Starting again.... ");
}
else
{
printf("Bye bye ");
break;
}
}
}

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote