Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Declare an array of five students 2) Using a for loop and getStudentInfo() fu

ID: 3771542 • Letter: 1

Question

1) Declare an array of five students

2) Using a for loop and getStudentInfo() function, get input of all the students

3) Using a for loop and printStudentInfo() function, print all the output of all students.

Here is the getStudentInfo() function:

#include
#include
struct student_t
{
   char name[20];
};

struct student_t getStudentInfo()
{
   struct student_t s;
   printf("Enter Student Name");
   scanf("%s",&s.name);
   return s;
}

Here is the printStudentInfo() function:

void printStudentInfo(struct student_t st_ptr)
{
   printf("Student name is %s",st_ptr.name);
}

void main()
{
   struct student_t ss;
   ss=getStudentInfo();
   printStudentInfo(ss);
   getch();
}

Explanation / Answer

1) Declare an array of five students or n students:

#include<stdio.h>
#include<conio.h>
struct student
{
char name[25];
}stud[25];

void main()
{
int n,i;
clrscr();
printf(" Enter total number of students :");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf(" Enter the name of the %d-th student",i+1);
printf(" Name:");
scanf("%s",&stud[i].name);
}
printf(" STUDENTS DETAILS:");
for(i=0;i<n;i++)
{
printf(" Name:%s",stud[i].name);
}
getch();
}