im doin an assignment where these statements r required

1. Enter the id & four subject marks
2. Calculate the total and average
4. Print the grade wise
5. Print GRADE SHEET
6. Terminate the program

so far i manage to come up with this and yet there is still error to it

``````#include <stdio.h>

main(void)

void data_entry (int [], float [])

void calculate_grade (char [])

{
int choice; int id; float s1; char grade;

do{
printf ("1. Enter ID & 4 Subject mark\n");
printf ("3. Calculate the grade\n");
printf ("6. Terminate the program\n");
scanf ("%d", & choice);

switch (choice) {

case 1 : data_entry (id,s1); //function call
break;
case 3 : calculate_grade (grade); //function call
break;
}
}while (choice !=6);

return 0;
}

//Function for data_entry

void data_entry (int t_id[], float t_s1[]);
{
int i;
printf ("Enter 10 student ID & 1 Subject mark\n");
for (i=0;i<10;i++) {
scanf ("%d%f", t_id[i], t_s1[i]);
}

//Function to calculate grade

{
int i;
for (i=0;i<10;i++){
if (t_s1[i] >=50)
else if ((t-s1[i]>=50)&&(t_s1[i]<60))
else if ((t_s1[i]>=60)&&(t_s1[i]<75))
else if (t_s1[i]>=75)

}
return;
}``````

what's wrong and what's missing here? plz help, desperately need to understand.... thanks

## All 9 Replies

u have defined the function
twice mistakably.
and please tell what r the errors

The prototypes end with a semicolon, the function definitions don't.
The prototypes should be before main(), not between main() and its {.
Make the prototypes match the definitions with respect to formal parameters.
Statements end in a semicolon (in your if tree).
Match all your opening braces with closing braces in data_entry.

Take another spin, and post code within CODE tags.

here are the errors in the program, the weird thing is someone did it wit the same codes and it works, maybe i got something wrong somewhere.

warning C4518: 'void ' : storage-class or type specifier(s) unexpected here; ignored
error C2146: syntax error : missing ';' before identifier 'data_entry'
fatal error C1004: unexpected end of file found
Error executing cl.exe.

thanks so much for the people who has replied.

here's the new version of my codes, plz correct me if there is anythin wrong or missing

``````/*function declaration*/

#include <stdio.h>

void data_entry (int [], int [], int [], int [], float [], float [], float [], float []);
void calculate_average ;
void calculate_grade (char [], char [], char [], char []);

main(void)

{
int choice; int id; int total; int average; float s1, s2, s3, s4; char grade;

do{
printf ("1. Enter student ID & 4 Subject mark\n");
printf ("2. Calculate Total & Average\n")
printf ("3. Calculate the grade\n");
printf ("4. Print Grade\n");
printf ("5. Print Grade Sheet\n");
printf ("6. Terminate the program\n");
scanf ("%d", & choice);

switch (choice) {

case 1 : data_entry (id,s1, s2, s3, s4); //function call
break;
case 2 : calculate_average ; //function call
break;
case 3 : calculate_grade (grade); //function call
break;
case 4 : grade_wise ; //function call
break;
case 5 : grade_sheet; //function call
break;

}
}while (choice !=6);

return 0;
}

//Function for data_entry

void data_entry (int t_id[], float t_s1[]);

{

int i;
printf ("Enter 10 student ID & 4 Subject mark\n");
for (i=0;i<10;i++) {
scanf ("%d%f", t_id[i], t_s4[i]);

}

//Function for calculate_average

void calculate_average

{
int i;
for (i=0;i<10;i++){
total = s1+s2+s3+s4;
printf ("The Total = %d\n", total);
average =(s1+s2+s3+s4)/4;
printf ("The Average = %d\n", average);

}

//Function to calculate grade

{
int i;
for (i=0;i<10;i++){
if (t_s1[i] >=50)
else if ((t-s1[i]>=50)&&(t_s1[i]<60))
else if ((t_s1[i]>=60)&&(t_s1[i]<75))
else if (t_s1[i]>=75)

}
return 0;

}``````

c++ is not somethin i know that well

<< moderator edit: added [code][/code] tags, please start using them yourself >>

return 0;

}

whats that going to..? Look at your compound statements my friend.

``````void calculate_grade (float t_s4[], char t_grade[]); //doesnt need semicolon its the function body!!!!
{ //start of function
int i;
for (i=0;i<10;i++){
if (t_s1[i] >=50)
else if ((t-s1[i]>=50)&&(t_s1[i]<60))
else if ((t_s1[i]>=60)&&(t_s1[i]<75))
else if (t_s1[i]>=75)

} //end of function
return 0; //you cant return something since your not in a scope... Also if you wanted to return 0 from your code - (that function you need to make it an int - Void tells the compiler that you are not returning a value from the function

} //whats this for?!?!``````

c++ is not somethin i know that well --- > This is not c++ its a corss over from c and c++

I'm sorry, im really new to this, im majoring in another field but i need to do this project to fulfill the requirements. im completely blur wit all these codes, surprisingly i manage to came out wit wut i know. sorry if i offended anyone wit this post

does it have to be done in C or C++?

from wut the lecturer been teachin, it's mainly c++

can you post up the question and I'll have a play

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.