Write a C program to find the arithmetic mean of a given list of n real values using pointers.

#include <stdio.h>

int main(){
  int n;
  printf("How many values: ");
  scanf("%d", &n);
 
  float x[n], mean;
 
  printf("Enter all values in the list: \n");
 
  for(int i=0; i<n; i++){
    scanf("%f", (x+i));
    mean += *(x+i);
  }
  mean/=n;
 
  printf("Arithmetic mean = %0.3f\n", mean);

  return 0;
}

Comments