Question

Declare an array of 40 student_t structures, and write a code segment that displays on separate...

Declare an array of 40 student_t structures, and write a code segment that displays on separate lines the names (last name, first name) of all the students in the list. IN C 
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi there,

The code :

#include<stdio.h>
typedef struct{
   char first[50];   //to store first name
   char last[50];   //to store last name
}student_t;
int main()
{
   student_t stud[40];
   for(int i=0;i<40;i++)
   {
       printf("\nEnter the first name for student %d : ",i+1);
       scanf("%s",stud[i].first);   //input first name
       printf("\nEnter the last name for student %d : ",i+1);
       scanf("%s",stud[i].last);   //input last name
       printf("\n");
   }  
   for(int i=0;i<40;i++)
   {
       printf("\n%s %s",stud[i].first,stud[i].last);   //print the complete name
   }
   printf("\n");
   return 0;
}      

The code(screenshot) :

1 #include<stdio.h> 2 typedef struct{ char first[50]; //to store first name, 4 char_last[50]; //to store last name 5}student

The output(screenshot) :(4 inputs only)

Enter the first name for student 1 : asd Enter the last name for student 1 : af Enter the first name for student 2 : gr Enter

Thank you.

Happy Coding :)

Add a comment
Know the answer?
Add Answer to:
Declare an array of 40 student_t structures, and write a code segment that displays on separate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT