Write a program to accept the details of 2 students using structure

//this is a program to accept the details of 2 students
#include<stdio.h>
#include<conio.h>
void main()
{
struct student
{
char name[20];
int rollno;
float per;
}s1,s2;

//accepting the details pf first student

printf("\n\nEnter the Name, Roll no, Percentage of First student: ");
scanf("%s%d%f",s1.name,&s1.rollno,&s1.per);

//accepting the details of second students
printf("\n\nEnter the Name, Roll no, Percentage of Second student: ");
scanf("%s%d%f",s2.name,&s2.rollno,&s2.per);

//Displaying the Details

printf("\n\nDeatils of First Student: ");
printf("\n\nName=%s\n\nRoll No.=%d\n\nPercentage=%f",s1.name,s1.rollno,s1.per);

printf("\n\nDeatils of Second Student: ");
printf("\n\nName=%s\n\nRoll No.=%d\n\nPercentage=%f",s2.name,s2.rollno,s2.per);
}

Previous
Next Post »