Hi, I am doing a little work and I have this.
Code:
#include <stdio.h>
#include <stdbool.h>
#define NumberOfStudents 10
struct Student
{
int studentID;
float balanceOwed;
float gpa;
};
typedef struct Student student;
int main( int argc, char **argv )
{
int i;
int id;
int index = -1;
bool willGraduate = true;
Student student[]={
{10, 0.0, 1.0},
{20, 100.0, 3.0},
{30, 0.0, 3.5},
{40, -25.0, 3.25},
{50, 0.0, 3.75},
{60, 1000.0, 1.5},
{70, 0.0, 3.25},
{80, -50.0, 3.0},
{90, 0.0, 3.9},
{100, 1.0, 4.0}
}
printf( "Enter student ID: " );
scanf( " %d", &id );
for( i = 0; i < NumberOfStudents; i++ )
{
if( id == student[i].studentID )
{
break;
}
}
if( i >= 0 )
{
if( student[i].balanceOwed > 0.0 )
{
willGraduate = false;
printf( " Student owes ($%0.2f)\n",
student[i].balanceOwed );
}
if( student[i].gpa < 2.0 )
{
willGraduate = false;
printf( " This student has a low GPA (%.2f)\n", student[i].gpa );
}
if( willGraduate )
printf( " This student WILL graduate\n" );
else
printf( " and will NOT graduate\n" );
}
else
printf( " Sorry, student ID (%d) not found\n", id );
return( 0 );
}
Gives error here -->Student student[]={ of
'Student' undeclared (first use in this function).
(Each undeclared identifier is reported only once for each function it appears in.)
syntax error before "student".
Where have gone wrong?
thanks