Store Information of Students Using Structure

Store Information of Students Using Structure
In this program, a structure, student is created. This structure has three members: name (string), roll (integer) and marks (float). Then, we created a structure array of size 5 to store information of 5 students. Using for loop, the program takes the information of 5 students from the user and displays it on the screen.
Input:

Input information of 5 students.
Output:

Display information of every student.
Sample of input:

Jack 1 34.5
Tom 2 22.9
Jone 3 80.3
Mark 4 77.2
Jane 5 60.3

Sample of output:

Roll number: 1
Name: Jack
Marks: 34.5
Roll number: 2
Name: Tom
Marks: 22.9
Roll number: 3
Name: Jone
Marks: 80.3
Roll number: 4
Name: Mark
Marks: 77.2
Roll number: 5
Name: Jane
Marks: 60.3

#include<stdio.h>
typedef struct{
    int ID;
    char name[20];
    float C;
}Stu;
int main()
{
    Stu stu[5];
    int i;
    for(i=0;i<5;i++)
	{
        scanf("%s %d %f",&(stu[i].name),&(stu[i].ID),&(stu[i].C));
    }
    for(i=0;i<5;i++)
    {
        printf("Roll number: %d\nName: %s\nMarks: %.1f\n",stu[i].ID,stu[i].name,stu[i].C);
    }
    return 0;
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值