All pastes #41873 Raw Edit

Miscellany

public c v1 · immutable
#41873 ·published 2006-02-16 20:35 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <malloc.h>int main(){    int i, t, l, sum;    int *PIN;        /* read array's size*/    scanf("%d", &t);            /* allocate memory */    PIN = (int *) malloc(t * sizeof(int));    if (!PIN) {       fprintf(stderr, "Out of memory\n");       exit(1);    }    /* read values */    for(l=0; l<t; l++)    {        scanf("%d", &PIN[l]);    }        /* sum values */    sum = 0;    for(i=1; i<t; i++)    {        sum += PIN[i];    }        /* print the mean average */    printf("%f\n", (float)sum/t);            /* free the memory */    free(PIN);    return 0;}