sum average min max in c array

Solutions on MaxInterview for sum average min max in c array by the best coders in the world

showing results for - "sum average min max in c array"
Owen
05 Aug 2018
1#include <stdio.h>
2
3
4int main(){
5    int i,sum=0;
6    //declaring array
7    int score[7] = {67,55,98,88,90,76,89};
8    //finding sum of the array numbers
9    for(i = 0; i < 7; i++){
10        sum = sum + score[i];
11    }
12    
13    printf("Sum is %d\n",sum);
14    
15    //finding average
16    printf("Average is %d\n",sum/7);
17    
18    //finding max number
19    int max=score[0];
20    for(i = 0; i < 7; i++){
21        if(score[i] > max){
22            max = score[i];
23        }
24    }
25    
26    printf("Max number is %d\n",max);
27    
28    //finding min number
29    int min=score[0];
30    for(i = 0; i < 7; i++){
31        if(score[i] < min){
32            min=score[i];
33        }
34    }
35    printf("MIn number is %d\n",min);
36    
37    
38    
39    
40    
41    return 0;
42}