0 votes
208 views
in C programming by (98.9k points)
edited by
Write a program to store the information of student using structure.

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
#include <stdio.h>
struct student
{
    char name[50];
    int roll;
    float marks;
} s[100];

int main()
{
    int i,n;
    struct student s[100];

    printf("Enter total of students:");
    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        printf("\n Enter information of student %d:\n",i+1);
        printf("Enter name: ");
        scanf("%s", s[i].name);

        printf("Enter roll number: ");
        scanf("%d", &s[i].roll);

        printf("Enter marks: ");
        scanf("%f", &s[i].marks);
    }

    printf("Displaying Information:\n");
    for(i=0;i<n;i++)
    {
        printf("\n %d no. student info\n",i+1);
        printf("\t Name:%s\n ",s[i].name);
        printf("\t Roll number: %d\n",s[i].roll);
        printf("\t Marks: %.1f\n\n",s[i].marks);
    }

    return 0;
}

 

Related questions

0 votes
1 answer 203 views
0 votes
1 answer 312 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...