Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- struct nametype{
- char first[40];
- char last[40];
- };
- struct studenttype{
- int id;
- struct nametype name;
- };
- int main()
- {
- struct studenttype student[3];
- int i, n = 3;
- for(i=0; i<n; i++)
- {
- printf("\nEnter your student id %d: ", i+1);
- scanf("%d",&student[i].id);
- printf("\nEnter your first name %d:", i+1);
- scanf("%s", student[i].name.first);
- printf("\nEnter your last name %d:", i+1);
- scanf("%s", student[i].name.last);
- }
- for(i=0; i<n; i++)
- {
- printf("\nID: %d\n", student[i].id );
- printf("Name: %s %s\n", student[i].name.first, student[i].name.last);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement