Skip to content

Instantly share code, notes, and snippets.

@darkodemic
Last active August 29, 2015 14:22
Show Gist options
  • Save darkodemic/d343f092382494e7c3e9 to your computer and use it in GitHub Desktop.
Save darkodemic/d343f092382494e7c3e9 to your computer and use it in GitHub Desktop.
Unos niza i racunanje njegove srednje vrednosti
#include <stdio.h>
#include <stdlib.h>
//preprocessor
int main(){
printf("Unesite duzinu niza: ");
int d=0;
scanf("%d",&d);
float array[d];
for(int i = 0; i < d; i++){
printf("Unesite vrednost za %d. element: ", i+1);
scanf("%f",&array[i]);
puts("");
}
puts("");
float ukupno=0;
for(int i = 0; i < d; i++){
ukupno += array[i];
}
printf("Srednja vrednost niza jeste: %.4f", ukupno / d);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment