Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

can you please help me with my asigment ? i have tp write code in C that reads data from .txt files

g3rsiig3rsii albaniaPosts: 1

hi, i am new to programming and i have this homework that i just cant make it to work and idk why .
this is what ive got so far and i have to turn this in in 5 hours , I'd really appreciate it if you would help me cuz im desperate
this programm has to read 6 names and 30 values , each name has 5 values corresponding to it ex 1st =1-5 2nd=6-10 etc and i have to calculate the averages of each student and write into a file the name of the student with the highest average/gpa

include<stdio.h>

include<conio.h>

include<stdlib.h>

include<string.h>

int main ()
{
FILE *fpgrades = fopen("notat.txt", "r");
FILE *fpnames = fopen("emrat.txt","r");
FILE *fpgpa = fopen("best.txt","w");;

char emri[6];
float m;
int s=0;

char best;
int values[30];
float max=0.0 ;
int a=1;

for (int i=1; i<=30; i++)
{
int c;
do
{
c = fscanf(fpgrades,"%d",values);
values[i]=c;
} while (c != EOF);
}

for(int k=1;k<=30;k++)
{printf("%d",values[k]);}



for(int i=1;i<=6;i++)
{
     for(int j=i*5;j>((i*5)-5);j--)
     {s=s+vlerat[j]; }   
        m=s/5;
        if(m>max)
        {max=m; best=emri[i];}
        }


fprintf(fpmes, "nxenesi me mesataren me te larte eshte %s\n", best);

getch();
return 0;
}
Sign In or Register to comment.