Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Accepting student marks.

Write a C program using structure to accept the marks of 3 subjects of 'n' students at a
time and find the marks

Sure, here's a C program that uses a structure to accept the marks of 3 subjects for 'n'
students at a time and finds the total marks:

c Copy code

#include <stdio.h>

struct student {
int subject1;
int subject2;
int subject3;
int total;
};

int main() {
int n, i;
printf("Enter the number of students: ");
scanf("%d", &n);

struct student students[n];

for (i = 0; i < n; i++) {


printf("Enter the marks of student %d: ", i + 1);
scanf("%d %d %d", &students[i].subject1, &students[i].subject2, &

students[i].total = students[i].subject1 + students[i].subject2 +


}

printf("\n\nStudent\t\tTotal Marks\n");
for (i = 0; i < n; i++) {
printf("Student %d\t%d\n", i + 1, students[i].total);
}

return 0;
ChatGPT }
Feb 13 Version. Free Research Preview. Our goal is to make AI systems more natural and safe to interact with. Your
feedback will help us improve.

You might also like