0% found this document useful (0 votes)
0 views2 pages

C Programming Ex9

The document outlines a C program designed to collect and print student information, including names and marks, while calculating total and average marks using structures. It details the procedure for implementing the program, including structure declaration, data input, and output display. The program successfully executes the intended functionality, demonstrating the use of structures in C programming.

Uploaded by

Malathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views2 pages

C Programming Ex9

The document outlines a C program designed to collect and print student information, including names and marks, while calculating total and average marks using structures. It details the procedure for implementing the program, including structure declaration, data input, and output display. The program successfully executes the intended functionality, demonstrating the use of structures in C programming.

Uploaded by

Malathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

EX.

NO: 9 PROGRAM TO COLLECT AND PRINT STUDENT


INFORMATION USING THE STRUCTURE
DATE:
AIM
Write a C program to collect and print students' details like name,
marks, etc., and then calculate the total and average marks using
structure.

PROCEDURE:
Step 1:
Start
Step 2:
Declare the structure using the struct keyword
Step 3:
Read the number of students
Step 4:
Using the loop read the student information like regno, name
and three subject mark
Step 5: calculate the total and average for all the student
Step 5: Display all the information
Step 7: Stop

PROGRAM:
#include <stdio.h>
#include <conio.h>

struct student {
char name[50];
int roll;
int m1,m2,m3,total;
float avg;
} s[5];

void main() {
int i,n;
clrscr();
rintf("Enter Number of Students : ");
scanf("%d",&n);
printf("Enter information for %d students:\n",n);
for(i=0;i<n;i++)
{
s[i].roll = i + 1;
printf("\n For roll number %d,\n", s[i].roll);
printf("Enter name: ");
scanf("%s", s[i].name);
printf("Enter marks 3 subject Marks ");
scanf("%d", &s[i].m1);
scanf("%d", &s[i].m2);
scanf("%d", &s[i].m3);
}
printf("Displaying Information:\n\n");
printf("\n R.No \t Name \t Total \t Average");
for (i = 0; i < n; ++i) {
s[i].total = s[i].m1+s[i].m2+s[i].m3;
s[i].avg = s[i].total /3.0;
printf("\n %d\t\t %s\t %d \t %.2f",s[i].roll,s[i].name, s[i].total,
s[i].avg);
}
getch();
}

RESULTS:
Thus, the C program to collect and print students' details using
structure was successfully executed.

You might also like