Write a program in c to display student data using structure
#include<stdio.h>
#include<conio.h>
void main()
{
struct student
{
int rollno;
char name[20];
char combination[4];
float percentage;
};
struct student s1;
clrscr();
printf("Enter the roll number: ");
scanf("%d",&s1.rollno);
printf("Enter the name of the student: ");
scanf("%s",s1.name);
printf("Enter the combination: ");
scanf("%s",s1.combination);
printf("Enter the percentage: ");
scanf("%f",&s1.percentage);
printf("Roll number=%d\n",s1.rollno);
printf("Name of the student=%s\n",s1.name);
printf("Combination=%s\n",s1.combination);
printf("Percentage=%f\n",s1.percentage);
getch();
}
Output:
Enter the roll number: 1
Enter the name of the student: Hanumanth
Enter the combination: pcmc
Enter the percentage: 80
Roll number=1
Name of the student=Hanumanth
Combination=pcmc
No comments: