March 31, 2015

Homework Help: C programming

Posted by E on Saturday, October 2, 2010 at 7:49pm.

Question: Write a program that reads integers from the keyboard until the user enters the sentinel value -999. The program should then print the minimum integer read, the maximum integer read and the average of all the integers. (Excluding the sentinel value -999)

I know how to post maxes & mins and set the sentinel value. I don't know how to tell the computer to sum up the values given and take the average since I need a generic function that would work for any number of values.

My code for everything else:

#include <stdio.h>

int main()

int num;
int min;
int max;
int avg;

printf("Enter a number (-999 to quit): ");

//putting the first number the user entered in variable min and max
min = num;
max = num;

min = num;

max = num;
printf("Enter another number (-999 to quit): ");

printf("\nThe smallest number entered is %d\n",min);
printf("\nThe largest number entered is %d\n",max);

return 0;

Answer this Question

First Name:
School Subject:

Related Questions

PROGRAMMING - 1. Make a C program that will input two integers and then to enter...
C programming - Build a program that allows a user to select one of the ...
programming MIPS ask - Write a MIPS assembly language program that will cover ...
programming - I am supposed to modify this program so it begins by asking the ...
Programming - Write a pseudocode program that asks the user for an integer ...
Programming in c++ - Draw a flow-chart and Write a program that asks the user ...
java - Write a program that reads a five digit integer number from the keyboard...
C Programming - Write a program that prompts the user to enter a temperature, ...
Programming (Integer generator) - Write a program that accepts two numeric ...
Computers (Programming by Python) - Problem 1: Multiplication Drill Computers ...