Help with c+ programing

ok i missed a day of school and the book they gave us for class is sooo confusing so can you help me?

i got to write a program that has N number of inputs

i take those inputs and find the sum average, smallest, and largest.

well i got the smallest and average part dont i cant figure out how to do the largest though this stuff is sooooo hard.

heres what i got so far


#include <stdio.h>

int main()
{
float smallest, largest, average, num, sum=0;
int N, i;


printf("enter the number of inputs >");
scanf("%d",&N);


for(i=0; i < N;i++)
{
printf("enter number > ");
scanf("%f", &num);
sum = sum + num;
if(i== 0)
smallest = num;
if(smallest > num)
smallest = num;
}


average = sum/N;

printf("the average = %f\n", average);
printf("the smallest = %.2f\n", smallest);
// printf("the largest = %f.2\n", largest);

return 0;
}
1 answer Last reply
More about help programing
  1. for(i=0; i < N;i++) # set i to 0; is i smaller than N; increment i by 1
    {
    printf("enter number > " );
    scanf("%f", &num);

    sum = sum + num;

    # the next step should only be done the first time through the loop
    if(i== 0)
    smallest = num;
    largest = num;

    # Assign num to smallest if num smaller than current
    if(smallest > num)
    smallest = num;

    # Assign num to largest if num larger than current
    if(largest < num)
    largest = num;
    }
Ask a new question

Read More

Programming Apps