Write a C language program to maintain a record of the student using structure.

Program Code:
#include<stdio.h>
#include<conio.h>
struct student
{
int rollno, marks;
char name[20], grade;
};
void main()
{
int i,n,found=0;
struct student s[10];
char sname[20];
clrscr();
printf("Enter the number of student details n=");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nenter the %d student details \n",i+1);
printf("enter the roll number:");
scanf("%d",&s[i].rollno);
printf("enter the student name without white spaces:");
scanf("%s", s[i].name);
printf("enter the marks : ");
scanf("%d", &s[i].marks);
printf("enter the grade : ");
fflush(stdin);
scanf("%c",&s[i].grade);
}
printf("\nStudent details are \n");
printf("\nRollno\tName\t\t\tMarks\tGrade\n");
for(i=0;i<n;i++)
printf("%d\t%s\t\t%d\t%c\n", s[i].rollno, s[i].name, s[i].marks, s[i].grade);
printf("\nEnter the student name to print the marks:");
scanf("%s", sname);
for(i=0;i<n;i++)
{
if(strcmp(s[i].name,sname)==0)
{
printf(“\Marks of the student is : %d”,s[i].marks);
found=1;
}
}
if(found ==0)
printf(“ Given student name not found\n”);
getch();
}

Output:
Enter the number of student details n=3

enter the 1 student details
enter the roll number: 100
enter the student name without white spaces:vishwa
enter the marks : 90
enter the grade : A
enter the 2 student details
enter the roll number: 101
enter the student name without white spaces:madhu
enter the marks : 50
enter the grade : B
enter the 3 student details
enter the roll number: 102
enter the student name without white spaces:kiran
enter the marks : 45
enter the grade : C

Roll Name Marks Grad
100 vishwa 90 A
101 madhu 50 B
102 kiran 45 C
Enter the student name to print the marks: madhu
Marks of the student is : 50
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: