EXP9 Writeup-1
EXP9 Writeup-1
EXP9 Writeup-1
Date of Performance:
Date of Submission:
Struct myStructure {
int myNum;
char myLetter;
};
int main() {
struct myStructure s1;
return 0;
}
Algorithm:
Start
Define a structure called student that contains:
● A character array name[20] to hold the student's name.
● An integer roll_no to hold the student's roll number.
● Three integers: physics, chem, and maths to hold the marks in respective subjects.
Declare an array st of type student to hold information for up to 100 students.
Declare an integer variable n to hold the number of students.
Print a message to the user asking for the number of students.
Read the value of n from the user.
For each student (i from 0 to n-1):
● Print a message asking for the student's name, roll number, and marks in physics,
chemistry, and maths.
● Read the student's name, roll_no, physics, chem, and maths using scanf.
Print a header for the student information table.
For each student (i from 0 to n-1):
● Print the student's name, roll_no, physics, chem, and maths.
End
Source Code:
#include<stdio.h>
#include<math.h>
struct student
{
char name[20];
int roll_no;
int physics,chem,maths;
};
void main()
{
struct student st[100];
int n,i,j;
printf("Enter the number of students:");
scanf("%d",&n);
for(i=0;i<=n-1;i++)
{
printf("Enter the student's name, roll number and marks in three subjects:");
scanf("%s %d %d %d %d" , st[i].name,&st[i].roll_no , &st[i].physics ,
&st[i].chem ,
&st[i].maths);
}
printf("Name\tRoll No\tPhysics\tChem\tMaths\n");
printf("----------------------------------------------\n");
for(i=0;i<=n-1;i++)
{
printf("%s\t%d\t%d\t%d\t%d\
n",st[i].name,st[i].roll_no,st[i].physics,st[i].chem,st[i].maths);
}
}
Output:
CONCLUSION:
R1 R2 R3 R4 R5 Total Signature
(3 Marks) (3 Marks) (3 Marks) (3 Mark) (3 Mark) (15 Marks)