0% found this document useful (0 votes)
5 views4 pages

PROGRAM 10 Structures

The document outlines a program to manage student data, including reading student details, calculating average marks, and identifying students who scored above or below this average. It provides an algorithm and a corresponding C program that implements the logic using structures. The program prompts for the number of students, collects their details, computes the average, and displays the results accordingly.

Uploaded by

nayana_y
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

PROGRAM 10 Structures

The document outlines a program to manage student data, including reading student details, calculating average marks, and identifying students who scored above or below this average. It provides an algorithm and a corresponding C program that implements the logic using structures. The program prompts for the number of students, collects their details, computes the average, and displays the results accordingly.

Uploaded by

nayana_y
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PROGRAM 10-

Implement structures to read, write, compute average- marks and the


students scoring above and below the average marks for a class of N students.

ALGORITHM-

Step 1 : Start

Step 2 : Define a Structure Student with members


usn,name,marks, Define a structure variable s

Step 3 : Read n

Step 4: for i0 to n do

Read s[i].usn, s[i].name,s[i].marks sumsum+s[i].marks

end for

Step 5 : avg←sum/n

Step 6 : Print avg

Step 7 : Print “Details of student who scored above average marks” for i0 to n do

if(s[i].marks>=avg)then

Print s[i].usn,s[i].name,s[i].marks

end if

end for

Step 8 : Print “Details of student who scored below average marks” for i0 to n do

if(s[i].marks<avg)then

Print s[i].usn,s[i].name,s[i].marks
end for

Step 9 : Stop

FLOWCHART-
PROGRAM-

#include<stdio.h>
struct student
{
int marks,usn;
char name[100];
};
void main()
{
struct student s[100];
int i,n;
float sum=0.0,avg=0.0;
printf("Enter the number of students\n");
scanf("%d",&n);
printf("Enter the student details\n");
printf("\n usn\t name\t marks\n");
for(i=0;i<n;i++)
{
scanf("%d%s%d",&s[i].usn,s[i].name,&s[i].marks);
sum=sum+s[i].marks;
}
avg=sum/n;
printf ("Average marks is %f",avg);
printf("Students who scored above average marks:\n");
printf("\nusn \t name \t marks \n");
for(i=0;i<n;i++)
{
if(s[i].marks>=avg)
{
printf("%d\t%s\t%d\n",s[i].usn,s[i].name,s[i].marks);
}
}
printf("\nStudents scored below average marks:\n");
printf("\n usn\t name\t marks \n");
for(i=0;i<n;i++)
{
if(s[i].marks<avg)
{
printf("%d\t%s\t%d\n",s[i].usn,s[i].name,s[i].marks);
}
}
}

You might also like