Answer to Question #236666 in C for xyz

Question #236666

Create a class student which stores name, roll number and age of a student. Derive a

class test from student class, which stores marks in 5 subjects. Input and display the

details of a student.Extend this program to include a class sports, which stores the marks in sports activity.

Derive the result class from the classes ‘test’ and ‘sports’. Calculate the total marks and

percentage of a student.


1
Expert's answer
2021-09-14T00:41:51-0400
#include <stdio.h>
struct student {
    char Name[30];
    int roll_no;
    float marks;
    int age;
} m[5];
        
int main() {
    int x;
        printf("Enter information of students:\n");
        printf("\nFor roll number%d,\n", m[x].roll_no);
        printf("Enter first name: ");
        scanf("%s", m[x].Name);
        printf("Enter age: ");
        scanf("%d", &m[x].age);
       
        printf("Student Information:\n");
        printf("\nRoll number: %d\n", x + 1);
        printf("First name: ");
        puts(m[x].Name);
    
//class test
        int phy, chem, bio, math, comp; 
        float percentage;
     
        
       printf("Enter five subjects marks: ");
       scanf("%d%d%d%d%d", &phy, &chem, &bio, &math, &comp);
       percentage= (phy + chem + bio + math + comp)/ 5.0;
       printf("Percentage = %.2f\n", percentage);
// class sports
       int s1,s2,s3;
       printf("Input the marks in sports activities: ");
       scanf("%d%d%d",&s1,&s2,&s3);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS