Write a program to accept details of students into the structure and display roll number, name, marks in 3 subjects using pointer
#include<stdio.h>
int main()
{ int j;
struct student{
int rollno;
char name[50];
int marks[3];
}*ps;
printf("Enter your rollno: ");
scanf("%d", &ps->rollno);
fflush(stdin);
printf("Enter your name: ");
scanf("%[^\n]", &ps->name);
for(j=0;j<3;j++){
printf("Enter your marks: ");
scanf("%d", &ps->marks[j]);}
printf("\nRollNo: %d",ps->rollno);
printf("\nName: %s",ps->name);
for(j=0;j<3;j++){
printf("\nMarks: %d",ps->marks[j]);}
return 0;
}
Enter your rollno: 38 Enter your name: gaurav prajapati Enter your marks: 89 99 78 RollNo: 38 Name: gaurav prajapati Marks: 89 Marks: 99 Marks: 78