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

POP Lab Program 10-HMK

The document outlines a C program that implements structures to manage student data, including reading, writing, and calculating average marks. It allows users to input student details and displays the number of students scoring above and below the average. Additionally, it includes test cases and viva questions related to structures in C programming.

Uploaded by

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

POP Lab Program 10-HMK

The document outlines a C program that implements structures to manage student data, including reading, writing, and calculating average marks. It allows users to input student details and displays the number of students scoring above and below the average. Additionally, it includes test cases and viva questions related to structures in C programming.

Uploaded by

yuvarajravi456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Program 10: STRUCTURES

Write a program to implement structures to read, write and compute average- marks of
the students, list the students scoring above and below the average marks for a class of
N students.
Program
#include <stdio.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");
// storing information
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");
// displaying information
for(i=0; i<n; i++)
{
printf("\nUSN: %s\n",s[i].usn);
printf("Name: "); puts(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);
countav=0; countbv=0;
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);
}
Test Input Parameters Expected Obtained Remarks
No output output
1 N=3, Enter the student details Average Average
marks:520 marks:520
Total No of Total No of
students above students above
USN Name Marks average=1 average=1
Total No of Total No of PASS
S[0] 4GW24CS001 Chetana 500 students below students below
average=2 average=2
S[1] 4GW24CS002 Darshini 510

S[2] 4GW24CS003 Pallavi 550

2 N=2, Enter the student details Average Average


marks:540 marks:540
Total No of Total No of
students above students above
USN Name Marks average=1 average=1
Total No of Total No of PASS
S[0] 4GW24IS001 Rajini 520 students below students below
average=1 average=1
S[1] 4GW24IS002 Devika 560

Test for the following cases & record your observations


N=2, Enter the student details

USN Name Marks


3
S[0] 4GW24IS009 Rani 520

S[1] 4GW24IS006 Sita 560

Viva Questions:
1) Define structure? Differentiate between an array and a structure?
2) Does the definition of a structure create memory space?
3) How do you access a structure variable?
4) What is a enumerated data type in C?
5) Define union? What are the difference between structure and union?
6) What is the use of fflush( ).

You might also like