0% found this document useful (0 votes)
8 views5 pages

PGM 9

The document outlines an algorithm and C program to manage student data, including reading, writing, and calculating average marks for a class of N students. It involves creating a student structure with fields for USN, name, and marks, and then computes the average marks while counting students above and below this average. The program displays student information, average marks, and the counts of students based on their performance relative to the average.

Uploaded by

viveknaik2306
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)
8 views5 pages

PGM 9

The document outlines an algorithm and C program to manage student data, including reading, writing, and calculating average marks for a class of N students. It involves creating a student structure with fields for USN, name, and marks, and then computes the average marks while counting students above and below this average. The program displays student information, average marks, and the counts of students based on their performance relative to the average.

Uploaded by

viveknaik2306
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
You are on page 1/ 5

9.

Implement structures to read, write and 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: Create a structure with student including fields usn,name and marks. Step 3: Initialize the
variables countav=0,countbv=0

Step 4: Read the number of students n

Step 5: Read the value of usn, name and marks for the specified no of students using structure variable
s[i] for i=0 to n-1

Step 6: Display the details of students Step 7: Repeat for i=0 ton-1

Compute sum of the marks

Step 8: Compute the average

Step 9: Repeat for i=0 to n-1 If(s[i].marks>=average)

Print ” Total no of students above average” Else

Print “ Total number of students below average”

Step 10: Stop

Flow Chart:
#include<stdio.h>
#include<stdlib.h>
struct student
{
char usn[50];
char name[50];
int marks;
} s[10];
void main()
{
int i,n,countav=0,countbv=0;
float sum,average;
printf("Enter number of Students\n");
scanf("%d",&n);
printf("Enter information of students:\n");
for(i=0; i<n;i++)
{
printf("Enter USN: ");
scanf("%s",s[i].usn);
printf("Enter name: ");
scanf("%s",s[i].name);
printf("Enter marks: ");
scanf("%d",&s[i].marks);
printf("\n");
}
printf("Displaying Information:\n\n");
for(i=0; i<n; i++)
{
printf("\nUSN: %s\n",s[i].usn);
printf("Name: %s\n ", s[i].name);
printf("Marks: %d",s[i].marks);
printf("\n");
}
for(i=0;i<n;i++)
{
sum=sum+s[i].marks;
}
average=sum/n;
printf("\nAverage marks: %f",average);
for(i=0;i<n;i++)
{
if(s[i].marks>=average)
countav++;
else
countbv++;
}
printf("\nTotal No of students above average= %d",countav);
printf("\nTotal No of students below average= %d",countbv);
getch();
}

You might also like