[ create a new paste ] login | about

Link: http://codepad.org/U5WnyVsC    [ raw code | output | fork ]

C, pasted on Feb 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
int main(){
    int n = 3;
    float arr[3] = {40, 80, 60};
    float m = 0;
    int i;
    float sum = 0;

    for(i = 0; i < n; i++)
        m = arr[i] > m ? arr[i] : m;

    for(i = 0; i < n; i++){
        arr[i] = arr[i]/ m * 100;
        sum += arr[i];
    }
    printf("%.2f", sum / n);
    return 0;
}


Output:
1
75.00


Create a new paste based on this one


Comments: