C Program to Display the Details of Student Using Structure

In this program, you'll learn to declare structure student having member variables are roll-no., name and marks. Accept data for one student and display it.

Source Code

struct student
    int roll_no;
    char name[20];
    float marks;
int main()
    struct student s;
    printf("Enter student's roll number: ");
    scanf("%d", &s.roll_no);
    printf("Enter student's name: ");
    scanf("%s", s.name);
    printf("Enter student's marks: ");
    scanf("%f", &s.marks);
    printf("\nStudent's details are:");
    printf("\n Roll number=%d", s.roll_no);
    printf("\n Name=%s", s.name);
    printf("\n Marks=%f", s.marks);
    return 0;
Enter student's roll number: 5
Enter student's name: Santosh
Enter student's marks: 75.50

Student's details are:
 Roll number=5