No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
Hello again guys, I've created a bubblesort function to sort a string in chronological order, it is as follows: [CODE]void playerSort(int player, double ppg[]) { int i,j; char a[999][15]; char temp[15]; /* Converting LF into String */ for(i=0;i<player;i++) { sprintf(a[i],"%.2f",ppg[i]); } /* Sorting Array */ for(i=1;i<player;i++) for(j=0;j<player-i;j++) { if(strcmp(a[j+1],a[j])<0) { … |
|
Hey Guys, first year compsci student and I'm struggling with 2D arrays. Here is my code: [CODE] double classAverage(int assignments, int students) { double average,sum; int row,col; FILE *input_file; input_file=fopen("grades.txt","r"); for (col=0;col<assignments;col++) { sum=0; for (row=0;row<students;row++) { fscanf(input_file,"%lf",&grades[row][col]); while(fgetc(input_file) == ','); sum+=grades[row][col]; printf("%.2lf\n",sum); } } average=sum/students; fclose(input_file); return (average)[/CODE]; int … |