I am trying to write a program for my school assignment, but this programming thing is extremely hard, so I am looking some help in getting it done. The program i am writing is a basic grading system, where it should show the students class, and grade, and also calculate the students semester avg, exam grade and class grade. the semester avg is calculated by totaling the 2 exam grades and 3 class grades inputted and divide it by two to get the semester avg.

here is the program

#include<stdio.h>
#include<conio.h>
#include<string.h>

{

char studentname[31];
}
void Cal_semester_Grade(char*);
void Class_Grade(int,int,int);
void Exam_Grade(int,int);
void search_name(char);

void menu();
main()
{
int gradeave[30];
int choice,i;
int grade1, grade2, grade3;
char studname[30][25];
char classname[5];

menu()
printf("Please enter choice");
scanf ("%d",&choice);
switch (choice)
{
case 1:

for(i=0;i<30;i++)
{
printf("\n Please enter students name:");
scanf("%s",&studname[i]);
printf("\n Please enter students class name:");
scanf("%s",&classname);
Cal_semester_Grade(char studname[][30]);
}


Class_Grade();
break;

case 2:Cal_Semester_Grade();
break;
case 3:search_name();
break;
case 4:Menu();
default:
printf("You have entered an ivalid choice");
getch();
}


void menu()
{
printf ("**************WELCOME TO MAIN MENU*************");

printf ("\n1.Calculate semester average");
printf ("\n2.Calculate class grade");
printf ("\n3.Calculate Exam grade");
printf ("menu");
}


void  Class_Grade()
{
printf("Please enter Class grade")
scanf("%d%d%d",&grade1,&grade2,&grade3)


void Cal_semester_Grade()
{
printf("Please enter Exam grade");
Aia commented: For trying to use code tags on first post +15

> Is this your whole code as it won't compile using any compiler ?
> Can you please be more specific in what you need help with ?

> Is this your whole code as it won't compile using any compiler ?
> Can you please be more specific in what you need help with ?

that is where i reach in the code, i need help and advice as to what to do next, to write it.

that is where i reach in the code, i need help and advice as to what to do next, to write it.

If your program has to deal with multiple students' information I would use structures (structs) to store all the information related to them ...

My teacher said i should use a array, which i am using to store the information, but its confusing me, just started this thing, new to me, so i really done understand anything at all.

#include<stdio.h>
#include<conio.h>
#include<string.h>
{
char studentname[31];
}
void Cal_semester_Grade(char*);
void Class_Grade(int,int,int);
void Exam_Grade(int,int);
void search_name(char);

void menu();
main()
{
int gradeave[30];
int choice,i;
int grade1, grade2, grade3;
int exam1,exam2
char studname[30][25];
char classname[5];

menu()
printf("Please enter choice");
scanf ("%d",&choice);
switch (choice)
{
case 1:

for(i=0;i<30;i++)
{
printf("\n Please enter students name:");
scanf("%s",&studname[i]);
printf("\n Please enter students class name:");
scanf("%s",&classname);
Cal_semester_Grade(char studname[][30]);
}


Class_Grade();
break;

case 2:Cal_Semester_Grade();
break;
case 3:search_name();
break;
case 4:Menu();
default:
printf("You have entered an ivalid choice");
getch();
}


void menu()
{
printf ("**************WELCOME TO MAIN MENU*************");

printf ("\n1.Calculate semester average");
printf ("\n2.Calculate class grade");
printf ("\n3.Calculate Exam grade");
printf ("menu");
}


void  Class_Grade()
{
printf("Please enter Class grade")
scanf("%d%d%d",&grade1,&grade2,&grade3)


void Exam_grade()
{
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);

its confusing me

What's so confusing to you?
I would recommend to create a design of what your application has to be able to do and how you're going to achieve this before going onto the real coding part ...

void  Class_Grade()
{
printf("Please enter Class grade")
scanf("%d%d%d",&grade1,&grade2,&grade3)

void Exam_grade()
{
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);

has to be

void  Class_Grade()
{
printf("Please enter Class grade")
scanf("%d%d%d",&grade1,&grade2,&grade3)
}

void Exam_grade()
{
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
}

Remember that a function's body always has to be between a '{' and a '}' ...

ok kool, ill try do what i can, thanks though.

#include<stdio.h>
#include<conio.h>
#include<string.h>
{
char studentname[31];
}
void Cal_semester_Grade(char*);
void Class_Grade(int,int,int);
void Exam_Grade(int,int);
void search_name(char);

void menu();
main()
{
int gradeavg[30];
int choice,i;
int grade1, grade2, grade3;
int exam1,exam2
int examavg
char studname[30][25];
char classname[5];

menu()
printf("Please enter choice");
scanf ("%d",&choice);
switch (choice)
{
case 1:

for(i=0;i<30;i++)
{
printf("\n Please enter students name:");
scanf("%s",&studname[i]);
printf("\n Please enter students class name:");
scanf("%s",&classname);
Cal_semester_Grade(char studname[][30]);
}


Class_Grade();
break;

case 2:Cal_Semester_Grade();
break;
case 3:search_name();
break;
case 4:Menu();
default:
printf("You have entered an ivalid choice");
getch();
}


void menu()
{
printf ("**************WELCOME TO MAIN MENU*************");

printf ("\n1.Calculate class grade");
printf ("\n2.Calculate Exam grade");
printf ("\n3.Calculate semester grade");
printf ("\n4.Enter Student's Name");
printf ("menu");
}


void  Class_Grade()
{
printf("Please enter Class grade");
scanf("%d%d%d",&grade1,&grade2,&grade3);
gradeavg=(grade1+grade2+grade3/3);
}

void Exam_grade()
{
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
examavg=(exam1+exam2/2);
}

void Cal_semester_Grade

Is this correct up to the Cal_semester_grade function so far? Need to know so i can continue.

Your main() function misses a '}' at the end, your functions haven't specified their return value ...
If your function isn't returning a value then you should declare it as void: void [I]yourfunction[/I] Your main function doesn't return a value, declare it as int main() :

int main(void)
{
    /* The code of your main function here */
    return 0;
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
{
char studentname[31];
}
void Cal_semester_Grade(char*);
void Class_Grade(int,int,int);
void Exam_Grade(int,int);
void search_name(char);

void menu();
int main(void)
{
int gradeavg[30];
int choice,i;
int grade1, grade2, grade3;
int exam1,exam2
int examavg[30]
char studname[30][25];
char classname[5];
}

menu()
printf("Please enter choice");
scanf ("%d",&choice);
switch (choice)
{
case 1:

for(i=0;i<30;i++)
{
printf("\n Please enter students name:");
scanf("%s",&studname[i]);
printf("\n Please enter students class name:");
scanf("%s",&classname);
Cal_semester_Grade(char studname[][30]);
}


Class_Grade();
break;

case 2:Cal_Semester_Grade();
break;
case 3:search_name();
break;
case 4:Menu();
default:
printf("You have entered an ivalid choice");
getch();
}


void menu()
{
printf ("**************WELCOME TO MAIN MENU*************");

printf ("\n1.Calculate class grade");
printf ("\n2.Calculate Exam grade");
printf ("\n3.Calculate semester grade");
printf ("\n4.Enter Student's Name");
printf ("menu");
}


void  Class_Grade()
{
printf("Please enter Class grade");
scanf("%d%d%d",&grade1,&grade2,&grade3);
gradeavg=(grade1+grade2+grade3/3);
}

void Exam_grade()
{
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
examavg=(exam1+exam2/2);
}

void Cal_semester_Grade

Is that better?

commented: You're doing much effort and I really appreciate that :) +1

Is that better?

Yeah, that's a lot better :) ...

ok thanks, going to continue try a thing lol.

{
char studentname[31];
}

Why are you declaring studentname as a global variable ?

Just add char studentname[31]; to the beginning of your main function ...

#include<stdio.h>
#include<conio.h>
#include<string.h>
{

char studentname[31];

}
void Cal_semester_Grade(char*);
void Class_Grade(int,int,int);
void Exam_Grade(int,int);
void search_name(char);

void menu();
int main(void)
{
int gradeavg[30];
int choice,i;
int grade1,grade2,grade3;
int exam1,exam2;
int examavg[30];
char studname[30][25];
char classname[5];
}
{
Menu()
printf("Please enter choice");
scanf("%d",&choice);
switch (choice)
{
case 1:

for(i=0;i<30;i++)
{
printf("\n Please enter students name:");
scanf("%s",&studname[i]);
printf("\n Please enter students class name:");
scanf("%s",&classname);
Cal_semester_Grade(char studname[][30]);
}


Class_Grade();
break;

case 2:Cal_Semester_Grade();
break;
case 3:search_name();
break;
case 4:Menu();
default:
printf("You have entered an ivalid choice");
getch();
}


void menu()
{
printf ("**************WELCOME TO MAIN MENU*************");

printf ("\n1.Calculate class grade");
printf ("\n2.Calculate Exam grade");
printf ("\n3.Calculate semester grade");
printf ("\n4.Enter Student's Name");
printf ("menu");
}


void  Class_Grade()
{
printf("Please enter Class grade");
scanf("%d%d%d",&grade1,&grade2,&grade3);
gradeavg=(grade1+grade2+grade3/3);
}

void Exam_grade()
{
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
examavg=(exam1+exam2/2);
}

//////void Cal_semester_Grade//////

getch ();
}

i tried compiling what i have so far, and it give me some error, what could have caused that?

#include<stdio.h>
#include<conio.h>
#include<string.h>

void Cal_semester_Grade(char*);
void Class_Grade(int,int,int);
void Exam_Grade(int,int);
void search_name(char);

void menu();
int main(void)
{
int gradeavg[30];
char studentname[31];
int choice,i;
int grade1,grade2,grade3;
int exam1,exam2;
int examavg[30];
char studname[30][25];
char classname[5];
}
{
Menu()
printf("Please enter choice");
scanf("%d",&choice);
switch (choice)
{
case 1:

for(i=0;i<30;i++)
{
printf("\n Please enter students name:");
scanf("%s",&studname[i]);
printf("\n Please enter students class name:");
scanf("%s",&classname);
Cal_semester_Grade(char studname[][30]);
}


Class_Grade();
break;

case 2:Cal_Semester_Grade();
break;
case 3:search_name();
break;
case 4:Menu();
default:
printf("You have entered an ivalid choice");
getch();
}


void menu()
{
printf ("**************WELCOME TO MAIN MENU*************");

printf ("\n1.Calculate class grade");
printf ("\n2.Calculate Exam grade");
printf ("\n3.Calculate semester grade");
printf ("\n4.Enter Student's Name");
printf ("menu");
}


void  Class_Grade()
{
printf("Please enter Class grade");
scanf("%d%d%d",&grade1,&grade2,&grade3);
gradeavg=(grade1+grade2+grade3/3);
}

void Exam_grade()
{
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
examavg=(exam1+exam2/2);
}

//////void Cal_semester_Grade//////

getch ();
}

E.g: in your function Class_Grade() you're want to access the variable grade1, grade2, grade3 which you previously declared in the main-function, but this isn't allowed in C, you should pass these values as an argument, this is an example of a modified Class_Grade() function:

int Class_Grade()
{
    int g1, g2, g3, gradeavg;
    printf("Please enter Class grade");
    scanf("%d%d%d",&g1,&g2,&g3);
    gradeavg=(g1+g2+g3)/3;
    /* Put g1+g2+g3 between brackets because of the algebraic rules of math */
    return gradeavg;
}

E.g: in your function Class_Grade() you're want to access the variable grade1, grade2, grade3 which you previously declared in the main-function, but this isn't allowed in C, you should pass these values as an argument, this is an example of a modified Class_Grade() function:

int Class_Grade()
{
    int g1, g2, g3, gradeavg;
    printf("Please enter Class grade");
    scanf("%d%d%d",&g1,&g2,&g3);
    gradeavg=(g1+g2+g3)/3;
    /* Put g1+g2+g3 between brackets because of the algebraic rules of math */
    return gradeavg;
}

ok, but this is an example of C++ or C?

ok, but this is an example of C++ or C?

Sorry, it's a C example, I've changed the syntax in my code ...

void  Class_Grade()
{
int grade1,grade2,grade3,gradeavg;
printf("Please enter Class grade");
scanf("%d%d%d",&grade1,&grade2,&grade3);
gradeavg=(grade1+grade2+grade3)/3;
}

so this is how its done?

void  Class_Grade()
{
int grade1,grade2,grade3,gradeavg;
printf("Please enter Class grade");
scanf("%d%d%d",&grade1,&grade2,&grade3);
gradeavg=(grade1+grade2+grade3)/3;
}

so this is how its done?

Yeah, syntactically this is a correct function, but you forgot one thing: if the function is ready with it's execution what happens to the value in gradeavg? It's lost ...
The gradeavg variable in this function isn't the same one as the one you declared in your main function, this is another one, the name is the same, but it's another one :) ...

Edit:: For more information on this: http://irc.essex.ac.uk/www.iota-six.co.uk/c/d5_variable_scope.asp

ok......

Any other questions ?

no right now

Not*

#include<stdio.h>
#include<conio.h>
#include<string.h>

void Cal_semester_Grade(char*);
void Class_Grade(int,int,int);
void Exam_Grade(int,int);
void search_name(char);

void Menu();
int main(void)
{
///int gradeavg[30];
///char studentname[31];
int choice,i;
/////int grade1,grade2,grade3;
//////int exam1,exam2;
///int examavg[30];
char studname[30][25];
char classname[5];
{

Menu();
printf("Please enter choice");
scanf("%d",&choice);
switch (choice)
{
case 1:

for(i=0;i<30;i++)
{
printf("\n Please enter students name:");
scanf("%s",&studname[i]);
printf("\n Please enter students class name:");
scanf("%s",&classname);
Cal_semester_Grade(char studname[][30]);
}



break;

case 2:Cal_semester_Grade();
break;
case 3:search_name(25);
break;
case 4:Menu();
default:
printf("You have entered an ivalid choice");
getch();
}


void menu()
{
printf ("**************WELCOME TO MAIN MENU*************");

printf ("\n1.Calculate class grade");
printf ("\n2.Calculate Exam grade");
printf ("\n3.Calculate semester grade");
printf ("\n4.Enter Student's Name");
printf ("menu");
}


void  Class_Grade()
{
int grade1,grade2,grade3,gradeavg[30];
printf("Please enter Class grade");
scanf("%d%d%d",&grade1,&grade2,&grade3);
gradeavg[30]=(grade1+grade2+grade3)/3;
}

void Exam_grade()
{
int exam1,exam2,examavg[30];
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
examavg[30]=(exam1+exam2/2);
}

//////void Cal_semester_Grade//////

getch ();
}}

have 3 errors, need help with getting rid off them, so i can run what i have.

> case 2:Cal_semester_Grade(); You declared the Cal_semester_Grade(); to expect a pointer to a char so you need to pass it also :)

> You're declaring function void menu() inside the main function, function declarations in functions aren't allowed in C ...

> Cal_semester_Grade(char studname[][30]); this gives you an error

> Hope this helps :) !

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define max  30

void Cal_semester_Grade(char studname[][25],int gradeavg[max],int examavg[max]);
void Class_Grade(char studname[][25],char classname[5],int classgrd[max][3],int gradeavg[max], int Maxtestscr[][3],char subject[15]);
void Exam_Grade(char studname[][25],char classname[5],char subject [15],char examavg[max],int Maxtestscr[max][3],int examgrd[max][3];
//void search_name(char);
void Menu();
char studname[max][25];
int gradeavg[max];
int classgrd[max][3];
int examgrd[max][3]
char classname[5];
char subjectname [15];
char examavg[max];
int Maxtestscr[max][3];
///int examavg[30];



int main(void)
{

int choice,i;
/////int grade1,grade2,grade3;
//////int exam1,exam2;

{

Menu();
printf("Please enter choice");
scanf("%d",&choice);
switch (choice)
{
case 1:

   for(i=0;i<max;i++)
    {
      printf("\n Please enter students name:");
      scanf("%s",&studname[i]);
      printf("\n Please enter students class name:");
      scanf("%s",&classname[i]);
      printf("\n Please enter subject name:");
      scanf("%s",&subjectname[i]);
      printf("\n Please enter Class grade:");
      scanf("%s",&classgrd[i]);
      Class_Grade( studname,classname,classgrd,gradeavg,Maxtestscr,subjectname);
}

////Cal_semester_Grade( studname,gradeavg,examavg);

break;

//case 2:Cal_semester_Grade(studname);
//break;
//case 3:search_name();
//break;
//case 4:Menu();
default:
printf("You have entered an ivalid choice");
}
getch();
return 0;
}


void Menu()
{
printf("**************WELCOME TO MAIN MENU*************");

printf("\n1.Calculate class grade");
printf("\n2.Calculate Exam grade");
printf("\n3.Calculate semester grade");
printf("\n4.Enter Student's Name");
printf("\n.5Return to Menu");
getch();
}


void  Class_Grade(char studname[][25],char classname[5], int classgrd[max][3],int gradeavg[max], int Maxtestscr[][3],char subject [15])
{
     for(int a=0;a<max;a++)
     {
         for(int z=0; z<3;z++)
         {
            gradeavg[z]=classgrd[a][z]/Maxtestscr[a][z];
         }
     }

 }


/*int grade1,grade2,grade3,gradeavg[30];
printf("Please enter Class grade");
scanf("%d%d%d",&grade1,&grade2,&grade3);
gradeavg[30]=(grade1+grade2+grade3)/3;
}

void Exam_grade()
{
int exam1,exam2,examavg[30];
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
examavg[30]=(exam1+exam2/2);
}

//////void Cal_semester_Grade//////

getch ();
}}
 */


}

Getting errors, plz help debug

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define max  30

void Cal_semester_Grade(char studname[][25],int gradeavg[max],int examavg[max]);
void Class_Grade(char studname[][25],char classname[5],int classgrd[max][3],int gradeavg[max], int Maxtestscr[][3],char subject[15]);
void Exam_Grade(char studname[][25],char classname[5],char subjectname[15],int examavg[max],int Maxtestscr[max][3],int examgrd[max][3];
void Search_name(char);
void Menu();
char studname[max][25];
int gradeavg[max];
int classgrd[max][3];
int examgrd[max][3]
int semesteravg[max];
char classname[5];
char subjectname[15];
int examavg[max];
int Maxtestscr[max][3];





int main(void)
{

int choice,i,y,d;


{

Menu();
printf("Please enter choice");
scanf("%d",&choice);
switch (choice)
{
case 1:

   for(i=0;i<max;i++)
    {
      printf("\n Please enter students name:");
      scanf("%s",&studname[i]);
      printf("\n Please enter students class name:");
      scanf("%s",&classname[i]);
      printf("\n Please enter subject name:");
      scanf("%s",&subjectname[i]);
      printf("\n Please enter Class grade:");
      scanf("%s",&classgrd[i]);
      Class_Grade( studname,classname,classgrd,gradeavg,Maxtestscr,subjectname);
}

break;

case 2:
	for(y=0;y<max;y++)
    {
      printf("\n Please enter students name:");
      scanf("%s",&studname[y]);
      printf("\n Please enter students class name:");
      scanf("%s",&classname[y]);
      printf("\n Please enter subject name:");
      scanf("%s",&subjectname[y]);
      printf("\n Please enter exam grade:");
      scanf("%s",&examgrd[y]);
		Exam_Grade(studname,classname,subjectname,examavg,Maxtestscr,examgrd);

break;

case 3:
	for(d=0;d<max;d++)
   {
   	printf("\n Please enter students name:");
      scanf("%s",&studname[d]);
      printf("\n Please Exam Average:");
      scanf("%s",&examavg[d]);
      printf("\n Please enter Grade Average:");
      scanf("%s",&gradeavg[i]);
		Cal_semester_Grade(studname,gradeavg,examavg);

break;

case 4:Menu();
default:
printf("You have entered an ivalid choice");
}
getch();
return 0;
}


void Menu()
{
printf("**************WELCOME TO MAIN MENU*************");

printf("\n1.Calculate class grade");
printf("\n2.Calculate Exam grade");
printf("\n3.Calculate semester grade");
printf("\n4.Enter Student's Name to Search");
printf("\n5.5Return to Main Menu");
getch();
}


void  Class_Grade(char studname[][25],char classname[5], int classgrd[max][3],int gradeavg[max], int Maxtestscr[][3],char subject [15])
{
     for(int a=0;a<max;a++)
     {
         for(int z=0; z<3;z++)
         {
            gradeavg[z]=classgrd[a][z]/Maxtestscr[a][z];
         }
     }

 }



void Exam_Grade(char studname[][25],char classname[5],char subject [15],char examavg[max],int Maxtestscr[max][3],int examgrd[max][3];
{
	 for(int b=0;b<max;b++)
     {
         for(int c=0; c<3;c++)
         {
            examavg[c]=examgrd[b][c]/Maxtestscr[b][c];
         }
     }



}

void Cal_semester_Grade(char studname[][25],int gradeavg[max],int examavg[max]);
{
	for(int e=0;e<max;e++)

    {
         for(int f=0; f<1;f++)
         {
            semesteravg[f]=(examavg[e][f]+gradeavg[e][f])/2;
         }
     }

void Search_name(char);

getch ();
}}



}}

Need it debugged

Be a part of the DaniWeb community

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