#include<stdio.h>
struct student
{
int id;
char name[50];
float web_dev_marks;
float db_marks;
float cprog_marks;
float swsec_marks;
float total_marks;
float percentage;
};
int main()
{
int i, n=3;
struct student s[3];
// input data for 3 students
for(i=0; i<n; i++)
{
printf("Enter id, name, web dev marks, db marks, cprog marks, swsec marks of student %d:\n", i+1);
scanf("%d %s %f %f %f %f", &s[i].id, s[i].name, &s[i].web_dev_marks, &s[i].db_marks, &s[i].cprog_marks, &s[i].swsec_marks);
// check if marks are within the range of 0 to 100
if(s[i].web_dev_marks > 100 || s[i].db_marks > 100 || s[i].cprog_marks > 100 || s[i].swsec_marks > 100)
{
printf("Marks cannot be more than 100. Please re-enter the marks.\n");
i--;
continue;
}
// calculate total marks and percentage
s[i].total_marks = s[i].web_dev_marks + s[i].db_marks + s[i].cprog_marks + s[i].swsec_marks;
s[i].percentage = (s[i].total_marks / 400) * 100;
}
// display data in a proper format
printf("Id\tName\tWeb Dev\tDB\tC-Programming\tSoftware Sec\tTotal\tPercentage\n");
for(i=0; i<n; i++) {
printf("%d\t%s\t%.2f\t%.2f\t%.2f\t\t%.2f\t\t%.2f\t%.2f%%\n", s[i].id, s[i].name, s[i].web_dev_marks, s[i].db_marks, s[i].cprog_marks, s[i].swsec_marks, s[i].total_marks, s[i].percentage);
}
return 0;
}