You are on page 1of 2

#include<stdio.

h>
#include<conio.h>
struct student
{
int sno;
char name[20];
float m1,m2,m3;
};
void main()
{
struct student s;
clrscr();
printf("\n enter student number");
scnf("%d",&s.sno);
printf("\n enter student name");
fflush(stdin);
gets(s.name);
printf("\n enter marks in subject1");
scanf("%f",&s.m1);
printf("\n enter marks in subject2");
scamf("%f",&s.m2);
printf("\n enter marks in subject3");
printf("%f",&s.m3);
printf("\n \t \t STUDENT DETAILS");
printf("----------------------------");
printf("\n The student number %d of name %s has scored %f %f %f and a total of
%f",s.sno,s.name,s.m1,s.m2,s.m3,s.m1+s.m2+s.m3);
getch()
}

-----------------------------------------------------------------------------------
--------------------------------------------------------------------------------

#include<stdio.h>
#include<conio.h>
struct student
{
int rno;
char name[20];
float marks[3];
int total;
};
void main()
{
int i,j,n;
struct student s[10];
clrscr();
printf("\n enter number of students");
scanf("%d",&n);
printf("\n enter student details");
for(i=o;i<n;i++)
{
printf("\n enter %d student roll number",i+1);
scanf("%d",&s[i].rno);
printf("\n enter name ");
scanf("%s",&s[i].name);
printf("\n enter marks in 3 subjects");
for(j=0;j<3;j++)
{
scanf("%d",&s[i].marks[j]);
s[i].total=s[i].total+s[i].marks[j];
}
}
printf("\n displaying the student information");
for(i=0;i<n;i++);
{
printf("\n student %d rollnumber is %d",i+1,s[i].rno);
printf(",name is %s,s[i].name);
printf("marks are ");
for(j=0;j<3;j++);
{
printf("%f,s[i].marks[j]);
}
}
getch();
}

-----------------------------------------------------------------------------------
-----------------------------------------

You might also like