Program to illustrate student information using structure
#include <stdio.h>
struct student
{
// defining a structure
char name[33];
int sno,sub1,sub2;
float tot;
} s;
int main()
{
printf("\n Enter student number :");
scanf("%d",&s.sno);
printf("\n Enter student name :");
scanf("%s",s.name);
printf("\n Enter student mark in subject1 :");
scanf("%d",&s.sub1);
printf("\n Enter student mark in subject2 :");
scanf("%d",&s.sub2);
s.tot = s.sub1 + s.sub2;
printf("\n Total marks = %f ",s.tot);
return 0;
}
output:
#include <stdio.h>
struct student
{
// defining a structure
char name[33];
int sno,sub1,sub2;
float tot;
} s;
int main()
{
printf("\n Enter student number :");
scanf("%d",&s.sno);
printf("\n Enter student name :");
scanf("%s",s.name);
printf("\n Enter student mark in subject1 :");
scanf("%d",&s.sub1);
printf("\n Enter student mark in subject2 :");
scanf("%d",&s.sub2);
s.tot = s.sub1 + s.sub2;
printf("\n Total marks = %f ",s.tot);
return 0;
}
output:
No comments:
Post a Comment