Average, max, and min program in C

前端 未结 8 676
梦毁少年i
梦毁少年i 2021-01-21 02:55

So I\'m coding in C, and I need to come up with code that will take n numbers from the user, and find their minimum, maximum, average, and sum of squares for for their values. S

8条回答
  •  北海茫月
    2021-01-21 03:17

    Add a boolean, moved giving the values min, max 0 are the start of loop

    #include
    int main()
    {
        float average;
        int i, n, count=0, sum=0, squaresum=0, num, min, max;
    
        bool first = true;
        printf("Please enter the number of numbers you wish to evaluate\n");
        scanf_s("%d",&n);
    
        printf("Please enter %d numbers\n",n);
            min=0;
            max=0;
    
        while(countmax)
                   max=num;
                if(num

    Should also consider to check the return value of scanf

提交回复
热议问题