Last active
August 29, 2015 14:22
-
-
Save darkodemic/d343f092382494e7c3e9 to your computer and use it in GitHub Desktop.
Unos niza i racunanje njegove srednje vrednosti
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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