0% found this document useful (0 votes)
5 views1 page

structures in c programming

This C program collects and displays student records including roll numbers, names, and marks for three subjects. It calculates the average marks for each student and prints the details in a formatted output. The program allows input for a maximum of 100 students.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

structures in c programming

This C program collects and displays student records including roll numbers, names, and marks for three subjects. It calculates the average marks for each student and prints the details in a formatted output. The program allows input for a maximum of 100 students.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>

#define MAX 100

int main() {
int rollNo[MAX];
char name[MAX][50];
float marks[MAX][3];
float average[MAX];
int n;

printf("Enter number of students: ");


scanf("%d", &n);

// Input
for (int i = 0; i < n; i++) {
printf("\nEnter details for student %d\n", i + 1);
printf("Roll Number: ");
scanf("%d", &rollNo[i]);

printf("Name: ");
scanf(" %[^\n]", name[i]); // reads string with spaces

float sum = 0;
for (int j = 0; j < 3; j++) {
printf("Enter marks for subject %d: ", j + 1);
scanf("%f", &marks[i][j]);
sum += marks[i][j];
}
average[i] = sum / 3;
}

// Output
printf("\n--- Student Records ---\n");
for (int i = 0; i < n; i++) {
printf("Roll No: %d\n", rollNo[i]);
printf("Name: %s\n", name[i]);
printf("Marks: %.2f, %.2f, %.2f\n", marks[i][0], marks[i][1], marks[i][2]);
printf("Average: %.2f\n", average[i]);
printf("------------------------\n");
}

return 0;
}

You might also like