Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

take array input from user and calc the avr in c

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

    int sum, n, avr;
        scanf("%d",&n);
    int arr[n];
    for(int i=0; i<n ; i++){
        scanf("%d", &arr[i]);sum += arr[i];
    }
    avr=sum/n;
    /* printf("%d",sum); 
emove if u want to print the sum not avr*/
    printf("%d",avr);
return 0;
}
 
PREVIOUS NEXT
Tagged: #array #input #user #calc #avr
ADD COMMENT
Topic
Name
5+3 =