diff --git a/README.md b/README.md index df158a98..ec3de6b1 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/program-31/a.out b/program-31/a.out new file mode 100755 index 00000000..22b5b248 Binary files /dev/null and b/program-31/a.out differ diff --git a/program-31/program.c b/program-31/program.c index c6fbf3d8..43a5fffb 100644 --- a/program-31/program.c +++ b/program-31/program.c @@ -12,7 +12,7 @@ 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"); @@ -20,13 +20,13 @@ int main() 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); @@ -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); } diff --git a/program-32/program.c b/program-32/program.c new file mode 100644 index 00000000..26b3f3e9 --- /dev/null +++ b/program-32/program.c @@ -0,0 +1,29 @@ +#include +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; +}