Skip to content

Instantly share code, notes, and snippets.

Created June 5, 2015 15:22
Show Gist options
  • Save anonymous/ed32a0a5b165af326429 to your computer and use it in GitHub Desktop.
Save anonymous/ed32a0a5b165af326429 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
struct imenik{
char ime[30];
int brtel;
float prosek[10];
};
float average(int ocene[30], int f){
int a;
float y=0,x=0;
for(a=0;a<f;a++){
x+= ocene[a];
}
y = x/f;
return y;
}
main(){
int i,n,f=0, ocene[30];
float y;
struct imenik x;
printf("Unesite ime:");
scanf("%s",&x.ime);
printf("Vase ime je:%s\n",x.ime);
printf("Unesite broj telefona:\n");
scanf("%d",&x.brtel);
printf("Vas broj telefona je:%d\n",x.brtel);
printf("Unesite broj predmeta:");
scanf("%d",&n);
for(i=0;i<n;i++){
printf("Ocena:");
scanf("%d",&ocene[i]);
f++;
}
y = average(ocene,f);
printf("Vas prosek je %lf",y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment