0% found this document useful (0 votes)
19 views3 pages

Struct Programs

The document contains two C programs related to student information management. The first program collects and displays a student's name, roll number, and marks, while the second program calculates and displays the total marks of multiple students across five subjects. Both programs utilize a structure to store student data and involve user input for data entry.

Uploaded by

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

Struct Programs

The document contains two C programs related to student information management. The first program collects and displays a student's name, roll number, and marks, while the second program calculates and displays the total marks of multiple students across five subjects. Both programs utilize a structure to store student data and involve user input for data entry.

Uploaded by

shehnass2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

A program to store information of a students and display


it
#include<stdio.h>
struct student
{
char name[10];
int rollno;
float marks;
}s;
main ( )
{

printf("enter the information\n");


printf("enter the name\n");
scanf("%s",s.name);
printf("enter the roll number\n");
scanf("%d",&s.rollno);
printf("enter the marks\n");
scanf("%f",&s.marks);

printf("Diplay information: \n");


printf("name: " );
puts(s.name);
printf("roll number: %d\n", s.rollno);
printf("marks: %f\n", s.marks);
}

Output

enter the name


fgfg
enter the roll number
2
enter the marks
56
Diplay information:
name: fgfg
roll number: 2
marks: 56.000000

1.A program to find the total marks of n students

#include<stdio.h>
struct student
{
char name[10];
int rollno;
int subject[5],total;
};
main ( )
{
static struct student s[100];
int n,i,j;
printf("enter the no.of students\n");
scanf("%d",&n);
//printf("enter the marks of five subjects\n");
for(i=0;i<n;i++)
{
printf("enter student roll number \n");
scanf("%d",&s[i].rollno);
printf("enter student name \n");
scanf("%s", s[i].name);
printf("enter s[%d] student marks\n",i);
s[i].total=0;
for(j=0;j<5;j++)
{
scanf("%d",&s[i].subject[j]);
s[i].total=s[i].total+s[i].subject[j];
}
printf("%d\t%s\t%d\n",s[i].rollno,s[i].name,s[i].total);
}
}

Output
enter the no.of students 2

enter student roll number


1
enter student name
anu

enter s[0] student marks


1
2
3
4
5

1 anu 15
enter student roll number
2

enter student name


akhil

enter s[1] student marks


12
32
14
15
65
2 akhil 138

You might also like