Problem 81: Struct GPA

Create a simple structure named Student that holds the following variables-
i. id (integer)
ii. cgpa (float)
iii. name (string)
Now create an instance of that structure named s1 and scan the values from the user. Finally print the id, cgpa and name which user entered.

 

1,544 total views, 9 views today

Comments

comments

One thought on “Problem 81: Struct GPA”

  1. #include
    struct record{
    int id;
    float cgpa;
    char name[15];

    };

    int main()
    {
    struct record a[5];
    int i,n;
    for(i=0;i<5;i++)
    {
    printf("Enter id:\n");
    scanf("%d",&a[i].id);

    printf("Enter cgpa: \n");
    scanf("%f",&a[i].cgpa);

    printf("Enter name: \n");
    scanf("%s",a[i].name);
    printf("\n");

    printf("id: %d\ncgpa:%0.2f\nname:%s\n",a[i].id,a[i].cgpa,a[i].name);
    printf("\n");

    }

    }

Leave a Reply

Your email address will not be published.