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: 1. ask the

ID: 3694962 • Letter: D

Question

Design and write a modular C program to perform the following tasks: 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 num[50] ,sum=0,max=num[0],min=num[0],i;
    printf("Enter a positive number in between 1 and 23: ");
    for(i=0;i<50;i++)
    {
    if(1<=num[i]<=23)
    {
    scanf("%d",&num); /* Storing a integer entered by user in variable num */
    sum+=num[i];
    }
    else
    {
        printf("Number is valid only if it is between 1 and 23 ");
    }
    if(sum<98)
    {
          printf("Enter the next number");
    }
else
{
     break;
}
if(num[i]>max)
{
     max=num[i];
}
else if (num[i] < min)
    {
         min = num[i];
    }
    }
    printf("The sum of the numbers entered is %d and the largest number entered is %d and smallest number entered is %d",&sum,&max,&min);
    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