Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct Student{
- int indeks;
- int predmet;
- int ocjena;
- };
- int main() {
- FILE *ulaz;
- struct Student s[100];
- int brojac=0;
- float prolaz=0;
- int i;
- int slusao=0;
- int predmt;
- float suma=0;
- ulaz = fopen("ispiti.txt", "r");
- if (ulaz == NULL) {
- printf ("Pogreska kod otvaranja datoteke ispiti .txt!\n");
- exit(1);
- }
- while(fscanf(ulaz," %d %d %d\n",&s[brojac].indeks,&s[brojac].predmet,&s[brojac].ocjena)==3){
- brojac++;}
- printf("Unesite predmet: ");
- scanf("%d",&predmt);
- for(i=0;i<brojac;i++){
- if(s[i].predmet==predmt){
- suma+=s[i].ocjena;
- slusao++;
- if(s[i].ocjena>=6)
- prolaz++;
- }
- }
- if(slusao==0){
- printf("Zalimo, ali ne postoje podaci o predmetu sa brojem %d!",predmt);
- return 1;
- }
- printf("Prosjecna ocjena: %.2f\n",suma/slusao);
- printf("Prolaznost: %g%%",(prolaz/slusao)*100);
- fclose(ulaz);
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement