Knowee
Questions
Features
Study Tools

Write a C program using structure student which allows users to input details for three students including their names, roll numbers, and marks in 5 subjects. Use a function calculateTotalMarks(struct Student) which calculates the total marks and percentage for each student and displays the information. Each subject test is for 10 marks. Total marks = 50. Percentage = (marks obtained/total marks)*100.

Question

Write a C program using structure student which allows users to input details for three students including their names, roll numbers, and marks in 5 subjects. Use a function calculateTotalMarks(struct Student) which calculates the total marks and percentage for each student and displays the information. Each subject test is for 10 marks. Total marks = 50. Percentage = (marks obtained/total marks)*100.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple C program that meets your requirements:

#include <stdio.h>

struct Student {
    char name[50];
    int roll;
    int marks[5];
    int total;
    float percentage;
};

void calculateTotalMarks(struct Student *student) {
    student->total = 0;
    for(int i=0; i<5; i++) {
        student->total += student->marks[i];
    }
    student->percentage = (float)student->total / 50 * 100;
}

void display(struct Student student) {
    printf("Name: %s\n", student.name);
    printf("Roll: %d\n", student.roll);
    printf("Total Marks: %d\n", student.total);
    printf("Percentage: %.2f\n", student.percentage);
}

int main() {
    struct Student students[3];

    for(int i=0; i<3; i++) {
        printf("Enter details for student %d:\n", i+1);
        printf("Name: ");
        scanf("%s", students[i].name);
        printf("Roll: ");
        scanf("%d", &students[i].roll);
        printf("Marks in 5 subjects: ");
        for(int j=0; j<5; j++) {
            scanf("%d", &students[i].marks[j]);
        }
        calculateTotalMarks(&students[i]);
    }

    for(int i=0; i<3; i++) {
        printf("\nDetails for student %d:\n", i+1);
        display(students[i]);
    }

    return 0;
}

This program first defines a structure Student to hold the details of a student. It then defines a function calculateTotalMarks to calculate the total marks and percentage for a student. The display function is used to print the details of a student.

In the main function, it creates an array of Student structures to hold the details of three students. It then uses a loop to get the details of each student from the user, calculate the total marks and percentage, and display the details.

This problem has been solved

Similar Questions

You are developing a Student Record Management System in C. The system needs to store and manage information for multiple students, including their names, roll numbers, and marks obtained in different subjects. Implement array in structures to read, write, and compute average marks and the students scoring above and below the average marks for a class of N students. INPUT/OUTPUT EXAMPLE: Enter the number of students: 3 Enter details for 3 students: Student 1: Name: A Roll Number: 1 Marks in 5 subjects: Subject 1: 12 Subject 2: 13 Subject 3: 14 Subject 4: 15 Subject 5: 16 Student 2: Name: BB Roll Number: 2 Marks in 5 subjects: Subject 1: 11 Subject 2: 13 Subject 3: 12 Subject 4: 15 Subject 5: 14 Student 3: Name: CC Roll Number: 10 Marks in 5 subjects: Subject 1: 13 Subject 2: 14 Subject 3: 16 Subject 4: 17 Subject 5: 11 Class average marks: 13.73 Students scoring above average: A (Roll Number: 1) CC (Roll Number: 10) Students scoring below average: BB (Roll Number: 2)

We want to calculate the total marks of each student of a class in Physics,Chemistry and Mathematics and the average marks of the class. The number of students in the class are entered by the user. Create a class named Marks with data members for roll number, name and marks. Create three other classes inheriting the Marks class, namely Physics, Chemistry and Mathematics, which are used to define marks in individual subject of each student. Roll number of each student will be generated automatically using inheritance by c++

Java Program To Accept the Marks of a Student and Find the Total Marks and Percentage

Create a class called "Student" with private member variables for name, roll number, and marks in three subjects. Include public member functions to set the student details, calculate the average marks, and display the student detail

Write a C program to compute the maximum marks and average marks of a class using sentinel controlled repetition (-1 as the sentinel value)?- If user enters negative marks then display INVALID INPUT and and read the marks again.- If number of students is 0, then display "NO DATA"- If number of students > 0, then display maximum marks and the average marks separated by space.-You can assume that marks are integers and average also you discard decimal value.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.