13. C PROGRAMMING LAB | Check Now

C PROGRAMMING LAB – 13] Implement structures to read, write, compute average- marks and the students scoring above and below the average marks for a class of N students


C PROGRAMMING -Algorithm

  • Step-1: Start
  • Step-2: Read number of students
  • Step-3: For every student, read the student id, name , marks for all the subjects
  • Step-4: Calculate the avarage marks and store it in the avg field
  • Step-5: Print the results
  • Step-6: Initialise loop
  • Step-7: Read teh average of every student
  • Step-8: Check for if avg>35.00
  • Step-9: If yes than print the result else goto next interation
  • Step-10: Initialise the loop
  • Step-11: Read average of every student
  • Step-12: Check if avg<35.00
  • Step-13: If yes than print result else goto next iteration
  • Step-14: Stop
See also  6. C PROGRAMMING LAB | Check Now

Flow Chart

C PROGRAMMING-read, write, compute average- marks and the students scoring above and below the average marks for a class of N students

Program -13 source code

#include<stdio.h>
struct student 
{
char usn[10]; 
char name[10];
float m1,m2,m3;
float avg,total;
}; 
void main()
{
struct student s[20]; 
int n,i; 
float tavg,sum=0.0;
printf("Enter the number of student="); 
scanf("%d",&n);
for(i=0;i<n;i++)
{ 
printf("Enter the detail of %d students\n",i+1); 
printf("\n Enter USN=");
scanf("%s",s[i].usn);
printf("\n Enter Name="); 
scanf("%s",s[i].name);
printf("Enter the three subject score\n"); 
scanf("%f%f%f",&s[i].m1,&s[i].m2,&s[i].m3); 
s[i].total=s[i].m1+s[i].m2+s[i].m3; 
s[i].avg=s[i].total/3;
} 
for(i=0;i<n;i++)
{ 
 if(s[i].avg>=35) 
 printf("\n %s has scored above the average marks",s[i].name); 
 else 
 printf("\n %s has scored below the average marks",s[i].name); 
}
}

Output

Enter the number of students

2

  • Enter the details of 1 students
    • Enter USN = 100
    • Enter the name = Rude
    • Enter the three subject score = 10 21 15
  • Enter the details of 1 students
    • Enter USN = 222
    • Enter the name = Krish
    • Enter the three subject score = 11 9 10
See also  11. C PROGRAMMING LAB | Check Now

Rude has scored above the average marks

Krish has scored below the average marks

C PROGRAMMING -Viva Questions

1] What is structure?

2] How to declare a structure?

3] What is a structure member?

4] What is the difference between array and structure?

5] What is a nested structure?

6] What is typedef?

Leave a Reply

Your email address will not be published. Required fields are marked *

WhatsApp Icon Join For Job Alerts