473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Help me please { function }

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <ctype.h>
  5. #define MAX 30
  6.  
  7.  
  8. void getData (FILE*,int[],char[MAX][30],int[],int[],float[],float[],int[],int*);
  9. float computeTotal (int[],int[],float[],int[]);
  10. float maxScore(float*,float*);
  11. float minScore(float*,float*);
  12. float meanScore(float[],int[]);
  13. void showResult(FILE*,int[],char[],int[],int[],float[],int[],float[],float[],int*);
  14. void printline();
  15.  
  16. void main ()
  17. {
  18.    FILE *infile,*outfile;
  19.    int i;
  20.    if ((infile = fopen ("employee.txt","r"))==NULL)/*open file*/
  21.    {
  22.     printf("cannot open file.");  /*check file for exit*/
  23.     exit(0);
  24.    }
  25.  
  26.    getData (infile,id,name,test1,test2,mid,final,lab,&cnt);
  27.    com = computeTotal (test1,test2,mid,final,cnt);
  28.    max = maxScore(sum,cnt);
  29.    min = minScore(sun,cnt);
  30.    mean = meanScore(sum,cnt);
  31.    showResult(infile,id,name[MAX][30],mid,final,test_avg,lab,cnt);
  32. }
  33.  
  34. void getData (FILE*,int id [],char name [max][],int test1[],int test2[],float mid[],float final[],int lab[],int*cnt)
  35. {
  36.    while(!feof(infile))
  37.    {  /* read data from file*/
  38.    fscanf(infile,"%d  %s  %d  %d %f %f &d",&id[cnt],&name[cnt],&mid[cnt],&final[cnt],&test1[cnt],&test2[cnt],&lab[cnt]);
  39.    (*cnt)++;
  40.    }
  41. }
  42.  
  43. float computeTotal (int test1[],int test1[],float mid[],float final,int lab[],int*cnt)
  44. {
  45.    int i,sum=0;
  46.    for (i=0;i<cnt;i++)
  47.    {
  48.    test_avg = (test1[i]+test2[i])/2;
  49.    sum[i] = mid[i]+final[i]+test_avg+lab;
  50.    }
  51.    return sum[i];
  52. }
  53.  
  54. float maxScore (float sum[],int *cnt)
  55. {
  56.    int i,max=0,maxid;
  57.    for(i=0;i<cnt;i++)
  58.    {
  59.       if(sum[i]>max)
  60.          max=sum[i];
  61.          maxid=max;
  62.    (*cnt)++ ;
  63.    }
  64.    return maxid[i];
  65. }
  66.  
  67. float minScore (float sum[], int *cnt)
  68. {
  69.    int i, min = 100,minid;
  70.    for(i=0;i<cnt;i++)
  71.    {
  72.       if(sum[i]< min)
  73.          min=sum[i];
  74.          minid=min;
  75.    (*cnt)++ ;
  76.    }
  77.    return minid[i];
  78. }
  79.  
  80. float meanScore(float sum [],int *cnt);
  81. {
  82.    int i, mean;
  83.    float meantotal;
  84.    for(i=0;i<cnt;i++)
  85.    {
  86.    mean += sum[i];
  87.    meantotal = mean/cnt[i];
  88.    (*cnt)++ ;
  89.    }
  90.    return meantotal[i];
  91. }
  92.  
  93. void showResult(FILE*,int id[],char name[],float mid[],float final[],int lab[],int*);
  94. {  
  95.    int i;
  96.    outfile = fopen("REPORT.OUT","w");
  97.    fprintf(outfile,"                IT200   Score  Report\n");
  98.    fprintf(outfile,printline());
  99.    for(i=0;i<cnt;i++)
  100.    fprintf(outfile,"%d   %s   %d   %d   %.2f   %d   %.2f",id[i],name[i],mid[i],final[i],test_avg[i],lab[i],Total[i]");
  101.    fprintf(outfile,printline());
  102.    fprintf(outfile,"Average Score = %f\n,meantotal);
  103.    fprintf(outfile,"Max Score ::  %.2f  Score = %.2f" ,maxid[i],sum[i]);
  104.    fprintf(outfile,"Min Score ::  %.2f  Score = %.2f",minid[i],sum[i]);
  105.    fprintf(outfile,printline());
  106.  
  107.  
  108.    fclose(infile);
  109.    fclose(outfile);
  110.  
  111. }
  112.  
  113. void printline()
  114.    {
  115.    printf("---------------------------------------\n");
  116.    }
  117.  
*** 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. ^^
Attached Files
File Type: txt SCORE.txt (273 Bytes, 378 views)
Sep 14 '09 #1
6 1754
newb16
687 512MB
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.
Sep 14 '09 #2
MrPickle
100 100+
On line 34 and 93, you declare variables of type FILE* but you don't assign them a name.

Expand|Select|Wrap|Line Numbers
  1. 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*
Expand|Select|Wrap|Line Numbers
  1. void showResult(FILE*,int id[],char name[],float mid[],float final[],int lab[],int*);
Sep 14 '09 #3
donbock
2,426 Expert 2GB
@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.)
Sep 15 '09 #4
********************
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.*/
Sep 15 '09 #5
newb16
687 512MB
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.
Sep 15 '09 #6
donbock
2,426 Expert 2GB
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:
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. float computeTotal(int[],int[],float[],int[]);
Line 27:
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. 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!
Sep 15 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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...
6
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"...
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...
5
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...
7
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>...
5
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 ...
1
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....
22
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...
6
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,...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.