I need help with this question For the following C struct st

I need help with this question:

For the following C struct:

struct student {

int studentId;

char name[50];

char major[20];

float gpa;

}

Draw a type descriptor for type student using the information needed in the symbol table to describe this type.

I have created this so far but I am unsure of what the scope would be for each of these or if this is the correct kind of table.

.

Symbol Name Type Scope
student struct
studentID int
name char
major char
gpa float

Solution

#include <stdio.h>

FILE *f;

struct student

{

    char name[50];

    int id;

    int n;

    float sum;

    float gpa;

} s[100];

float FUN_GPA(int n);

int main ()

{

    int m,i,x,b;

    float max=0;

    s[i].sum=0;

    printf(\"Please Enter Number Of Students : \");

    scanf(\"%d\",&m);

    for(i=0;i<m;i++)

    {

        printf(\"\ Student %d : \ \",i+1);

        printf(\"Name : \");

        scanf(\"%s\",&s[i].name);

        printf(\"ID : \");

        scanf(\"%d\",&s[i].id);

        printf(\"Number Of Courses : \");

        scanf(\"%d\",&s[i].n);

    }

    printf(\"\ Enter Student Marks\");

    for(i=0;i<m;i++)

    {

        printf(\"\ \ \\t\\t\\t......[ Student %d ]......\ \",i+1);

        for(x=0;x<s[i].n;x++)

        {

            printf(\"Course %d Mark : \",x+1);

            scanf(\"%d\",&b);

            s[i].sum+=b;

        }

        printf(\"\ Sum Of The Courses Marks = %3.f\",s[i].sum);

        printf(\"\ GPA For Student %d = %f\",i+1,FUN_GPA(s[i].gpa));

    }  

    if (s[i].gpa>max)

        max=s[i].gpa;

    printf(\"\ \ Highest GPA is done by Student %d with GPA = %f\",i,max);

    {

        if((f=fopen(\"d:\\\\STUDENTS.txt\",\"w\"))==NULL)

            printf(\"\ cant open file \");

//      if((f=fopen(\"d:\\\\STUDENTS.txt\",\"r\"))==NULL)

//      printf(\"\ cant open file \");

        fprintf(f,\"Name : %s\\t ID : %d\\t GPA = %f \ \",s[i].name,s[i].id,s[i].gpa);

        fclose(f);

    }

}

float FUN_GPA(int i)

{

    s[i].gpa=0;

    s[i].gpa=s[i].sum/s[i].n;

    return s[i].gpa;

}

I need help with this question: For the following C struct: struct student { int studentId; char name[50]; char major[20]; float gpa; } Draw a type descriptor f
I need help with this question: For the following C struct: struct student { int studentId; char name[50]; char major[20]; float gpa; } Draw a type descriptor f
I need help with this question: For the following C struct: struct student { int studentId; char name[50]; char major[20]; float gpa; } Draw a type descriptor f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site