-
#include <stdio.h>
-
#include <string.h>
-
#include <conio.h>
-
#include <ctype.h>
-
#define MAX 30
-
-
-
void getData (FILE*,int[],char[MAX][30],int[],int[],float[],float[],int[],int*);
-
float computeTotal (int[],int[],float[],int[]);
-
float maxScore(float*,float*);
-
float minScore(float*,float*);
-
float meanScore(float[],int[]);
-
void showResult(FILE*,int[],char[],int[],int[],float[],int[],float[],float[],int*);
-
void printline();
-
-
void main ()
-
{
-
FILE *infile,*outfile;
-
int i;
-
if ((infile = fopen ("employee.txt","r"))==NULL)/*open file*/
-
{
-
printf("cannot open file."); /*check file for exit*/
-
exit(0);
-
}
-
-
getData (infile,id,name,test1,test2,mid,final,lab,&cnt);
-
com = computeTotal (test1,test2,mid,final,cnt);
-
max = maxScore(sum,cnt);
-
min = minScore(sun,cnt);
-
mean = meanScore(sum,cnt);
-
showResult(infile,id,name[MAX][30],mid,final,test_avg,lab,cnt);
-
}
-
-
void getData (FILE*,int id [],char name [max][],int test1[],int test2[],float mid[],float final[],int lab[],int*cnt)
-
{
-
while(!feof(infile))
-
{ /* read data from file*/
-
fscanf(infile,"%d %s %d %d %f %f &d",&id[cnt],&name[cnt],&mid[cnt],&final[cnt],&test1[cnt],&test2[cnt],&lab[cnt]);
-
(*cnt)++;
-
}
-
}
-
-
float computeTotal (int test1[],int test1[],float mid[],float final,int lab[],int*cnt)
-
{
-
int i,sum=0;
-
for (i=0;i<cnt;i++)
-
{
-
test_avg = (test1[i]+test2[i])/2;
-
sum[i] = mid[i]+final[i]+test_avg+lab;
-
}
-
return sum[i];
-
}
-
-
float maxScore (float sum[],int *cnt)
-
{
-
int i,max=0,maxid;
-
for(i=0;i<cnt;i++)
-
{
-
if(sum[i]>max)
-
max=sum[i];
-
maxid=max;
-
(*cnt)++ ;
-
}
-
return maxid[i];
-
}
-
-
float minScore (float sum[], int *cnt)
-
{
-
int i, min = 100,minid;
-
for(i=0;i<cnt;i++)
-
{
-
if(sum[i]< min)
-
min=sum[i];
-
minid=min;
-
(*cnt)++ ;
-
}
-
return minid[i];
-
}
-
-
float meanScore(float sum [],int *cnt);
-
{
-
int i, mean;
-
float meantotal;
-
for(i=0;i<cnt;i++)
-
{
-
mean += sum[i];
-
meantotal = mean/cnt[i];
-
(*cnt)++ ;
-
}
-
return meantotal[i];
-
}
-
-
void showResult(FILE*,int id[],char name[],float mid[],float final[],int lab[],int*);
-
{
-
int i;
-
outfile = fopen("REPORT.OUT","w");
-
fprintf(outfile," IT200 Score Report\n");
-
fprintf(outfile,printline());
-
for(i=0;i<cnt;i++)
-
fprintf(outfile,"%d %s %d %d %.2f %d %.2f",id[i],name[i],mid[i],final[i],test_avg[i],lab[i],Total[i]");
-
fprintf(outfile,printline());
-
fprintf(outfile,"Average Score = %f\n,meantotal);
-
fprintf(outfile,"Max Score :: %.2f Score = %.2f" ,maxid[i],sum[i]);
-
fprintf(outfile,"Min Score :: %.2f Score = %.2f",minid[i],sum[i]);
-
fprintf(outfile,printline());
-
-
-
fclose(infile);
-
fclose(outfile);
-
-
}
-
-
void printline()
-
{
-
printf("---------------------------------------\n");
-
}
-
*** error 25
***I do not understand about the parameters.***
***Then it will be searching & sorting again I do not understand the connection ***between this project.
--------------------------------------------------------------
help me please. T_T
Thank you for answers. ^^
6 1754
Just of curiosity I tried to compile it and here
getData (infile,id, <<
compiler issues an error about undefined id. (it also doesn't like conio.h, void main and exit() but it doesn't matter). Contact this code's author for support.
On line 34 and 93, you declare variables of type FILE* but you don't assign them a name. - void getData (FILE*,int id [],char name [max][],int test1[],int test2[],float mid[],float final[],int lab[],int*cnt)
You also do this with the last parameter here, of type int* - void showResult(FILE*,int id[],char name[],float mid[],float final[],int lab[],int*);
@natvarara
Next time please list the error messages verbatim. The text of compiler error messages is actually very good at identifying what the problem is. (Actually, I don't really mean "verbatim"; please translate all line numbers in the error messages to correspond to the line numbers of the source snippet inside your CODE tags.)
********************
getData (infile,id,name,test1,test2,mid,final,lab,&cnt);
Error Type mismatch in parameter 2 in call to 'getData'
Error Type mismatch in parameter 4 in call to 'getData'
Error Type mismatch in parameter 5 in call to 'getData'
Error Type mismatch in parameter 6 in call to 'getData'
Error Type mismatch in parameter 7 in call to 'getData'
Error Type mismatch in parameter 8 in call to 'getData'
com_t = computeTotal (test1,test2,mid,final,cnt);
Error Extra parameter in call to computTotal
/*I have tried to change some variables. */
/*It caused the error. Repeatedly in the same. I do not understand.*/
What is 'id' in call to getdata and why is it here?
Actually there are more errors than total lines of code. Try to make at least one small function like minScore compile and work, maybe event with preset data without getting it from file.
Line numbers are based on those in the first post. @natvarara
These error messages tell you there's something wrong with getData and computeTotal; so take a look at them ...
I searched your source file for the string "getData".
Line 8: - void getData(FILE*,int[],char[MAX][30],int[],int[],float[],float[],int[],int*);
The two-dimensional array argument almost certainly won't accomplish what you want. Take a look at Arrays Revealed.
Line 26: - getData(infile,id,name,test1,test2,mid,final,lab,&cnt);
Variables id, test1, test2, mid, final, lab, cnt not defined so I can't help you check if the types match.
Line 34: - void getData(FILE*,int id[], char name[max][],int test1[],int test2[],float mid[],float final[],int lab[], int*cnt)
No variable named for FILE* argument.
Change "max" to MAX in name argument.
Then I searched for "computeTotal".
Line 9: - float computeTotal(int[],int[],float[],int[]);
Line 27: - com = computeTotal(test1,test2,mid,final,cnt);
The prototype has four arguments, this call has five arguments!
Variables test1, test2, mid, final not defined so I can't help you check if the types match.
Line 43: - float computeTotal(int test1[],int test1[],float mid[], float final, int lab[], int*cnt)
The prototype has four arguments, this function definition has six arguments!
Two arguments are named test1.
Fourth argument of prototype has type int[], fourth argument of this function definition has type float.
All I did was compare these lines for consistency. You can do it!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: laurie |
last post by:
Hi all,
I'm trying to help out a friend who has inherited a client with a PHP
shopping cart application. Neither of us know PHP, but I've been
muddling my way through, trying to get these old...
|
by: James Walker |
last post by:
Can some one help I get an error of 'checkIndate' is null or not an object
can someone please help. I can't work out why
Thanks in advance
James
<form>
<td height="24" colspan="7"...
|
by: Alan Bashy |
last post by:
Please, guys, In need help with this. It is due in the next week. Please,
help me to implement the functions in this programm especially the first
three constructor. I need them guys. Please, help...
|
by: TrvlOrm |
last post by:
Can any one please help me...I am new to JavaScript and I have been
struggling with this code for days now and can't figure it out.
I would like to get the Buttons to correspond with the action...
|
by: x muzuo |
last post by:
Hi guys,
I have got a prob of javascript form validation which just doesnt work
with my ASP code. Can any one help me out please.
Here is the code:
{////<<head>
<title>IIBO Submit Page</title>...
|
by: Craig Keightley |
last post by:
Please help, i have attached my page which worksin IE but i cannnot get the
drop down menu to fucntion in firefox. Any one have any ideas why?
Many Thanks
Craig
...
|
by: al2004 |
last post by:
Write a program that reads information about youth soccer teams from a file, calculates the average score for
each team and prints the averages in a neatly formatted table along with the team name....
|
by: Amali |
last post by:
I'm newdie in c programming. this is my first project in programming.
I have to write a program for a airline reservation. this is what i
have done yet. but when it runs it shows the number of...
|
by: jenipriya |
last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors...
The table structures i hav
Employee (EmpID,...
|
by: gmdune |
last post by:
Hi All,
I have written a program that doesn't seem to work and I can't figure out why it's not working. It compiles correctly, but when I run it I get prompted by the first couple of printf...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |