Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
| Program-28 | Program to print the pattern |
| Program-29 | Program to print the pattern |
| Program-30 | Program to print the pattern |
| Program-31 | Program to print the details of students using array and to add details of new students into the existing array |
| Program-31 | Program to take the details of student and print the details of students using array and to add details of new students into the existing array |
| Program-31 | Program to take the details of student and print the details |
Binary file added program-31/a.out
Binary file not shown.
12 changes: 6 additions & 6 deletions program-31/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ int main()
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter the details of student-%d\n",i);
printf("Enter the details of student - %d\n",i);
printf("Enter the name of the student\n");
scanf("%s",&stud[i].n);
printf("Enter USN\n");
scanf("%s",&stud[i].u);
printf("Enter total marks\n");
scanf("%d",&stud[i].m);
}
printf("|\tSl.no\t|\tName\t|\tUSN\t\t|\tMark\t|\n");
printf("|\tSl.no\t|\tName\t\t|\tUSN\t\t|\tMark\t|\n");
for(i=1;i<=n;i++)
{
printf("|\t%d\t|\t%s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);
printf("|\t%d\t|\t%-10s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);
}
printf("Enter the details of new student\n");
printf("Enter the name\n"); //preferred to enter equal length of name
printf("Enter the name\n"); //preferred to enter equal length of name
scanf("%s",&stud2.n);
printf("Enter the USN\n");
scanf("%s",&stud2.u);
Expand All @@ -40,10 +40,10 @@ int main()
stud[i+1]=stud[i];
}
stud[p]=stud2;
printf("|\tSl.no\t|\tName\t|\tUSN\t\t |\tMark\t|\n");
printf("|\tSl.no\t|\tName\t\t|\tUSN\t\t |\tMark\t|\n");
for(i=1;i<=n+1;i++)
{
printf("|\t%d\t|\t%s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);
printf("|\t%d\t|\t%-10s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);

}

Expand Down
29 changes: 29 additions & 0 deletions program-32/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>
struct student
{
char n[100];
char u[100];
int m;
}stud[10],stud2;
int main()
{
int n,i,p=0;
printf("Enter the number of student\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter the details of student - %d\n",i);
printf("Enter the name of the student\n");
scanf("%s",&stud[i].n);
printf("Enter USN\n");
scanf("%s",&stud[i].u);
printf("Enter total marks\n");
scanf("%d",&stud[i].m);
}
printf("|\tSl.no\t|\tName\t\t|\tUSN\t\t|\tMark\t|\n");
for(i=1;i<=n;i++)
{
printf("|\t%d\t|\t%-10s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);
}
return 0;
}