Thanks for the help with the switching the program over to C programing. Here are the final errors i am getting
(49): error C2143: syntax error : missing ';' before 'type'
(56): error C2449: found '{' at file scope (missing function header(77): error C2059: syntax error : '}'
After i get this function working I need to have the program print out the student average. Right now i am just trying to understand how to make this structure stuff work to just do the class average , goal is student average.
Am i even close to getting this thing running. Let me know your suggestions.
thanks in advance for your help
main.c
Code:
#include "class_info.h"
#include <stdio.h>
int main(void)
{
struct student class[CLASS_SIZE];
class[0].grade = 'A';
class[0].last_name = "Walker";
class[0].student_id = 590017;
class[1].grade = 'B';
class[1].last_name = "Smith";
class[1].student_id = 590118;
class[2].grade = 'C';
class[2].last_name = "jones";
class[2].student_id = 590219;
class[3].grade = 'A';
class[3].last_name = "Bubba";
class[3].student_id = 590320;
class[4].grade = 'B';
class[4].last_name = "johns";
class[4].student_id = 590421;
class[5].grade = 'C';
class[5].last_name = "Walker";
class[5].student_id = 590017;
class[6].grade = 'D';
class[6].last_name = "Smith";
class[6].student_id = 590118;
class[7].grade = 'B';
class[7].last_name = "jones";
class[7].student_id = 590219;
class[8].grade = 'A';
class[8].last_name = "Bubba";
class[8].student_id = 590320;
class[9].grade = 'C';
class[9].last_name = "johns";
class[9].student_id = 590421;
void average( class, 10 )
return 0;
}
void average(struct student class[], int length);
{
double sum=0.0,avg;
int i;
int length = sizeof(class)/sizeof(student);
for( i=0;i<length;++i )
{
if( class[i].grade == 'A' )
sum+=4;
if( class[i].grade == 'B' )
sum+=3;
if( class[i].grade == 'C' )
sum+=2;
if( class[i].grade == 'D' )
sum+=1;
if( class[i].grade == 'F' )
sum+=0;
}
avg = (sum/length);
printf("The average for the class is %f.\n", avg)
}
return 0
here is my class_info.h file
Code:
#include <stdio.h>
#define CLASS_SIZE 100
struct student{
char *last_name;
int student_id;
char grade;
};