Write a program to accept details of students into the structure and display roll number, name, marks in 3 subjects.
#include<stdio.h>
struct student{
int rollno;
char name[50];
int m1,m2,m3;
} S1;
int main()
{
printf("Enter your rollno: ");
scanf("%d", &S1.rollno);
fflush(stdin);
printf("Enter your name: ");
scanf("%[^\n]", &S1.name);
printf("Enter marks in 3 subjects:\n");
scanf("%d %d %d", &S1.m1, &S1.m2, &S1.m3);
printf("\nRollNo: %d",S1.rollno);
printf("\nName: %s",S1.name);
printf("\nMarks in 3 Subjects: %d %d %d",S1.m1, S1.m2, S1.m3);
return 0;
}
Enter your rollno: 38 Enter your name: gaurav prajapati Enter marks in 3 subjects: 70 80 95 RollNo: 38 Name: gaurav prajapati Marks in 3 Subjects: 70 80 95