Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Home Work 14 @Nurnobi shanto
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct students
- {
- char name[15];
- char id[12];
- char sec[2];
- char dpt[20];
- struct students *next;
- } std;
- std *head = NULL;
- std *temp = NULL;
- void inestData()
- {
- printf("Enter number of total student:");
- int i,n;
- scanf("%d",&n);
- for(i=0; i<n; i++)
- {
- printf("\nEnter student information: #%d\n",i+1);
- std *newStd;
- newStd= (std*)malloc(sizeof(std));
- printf("Enter Name:");scanf("%s", &newStd-> name);
- printf("Enter ID:");scanf("%s", &newStd-> id);
- printf("Enter Section:");scanf("%s", &newStd-> sec);
- printf("Enter Department:"); scanf("%s", &newStd-> dpt);
- newStd->next=NULL;
- if(head==NULL)
- {
- head=newStd;
- }
- else
- {
- temp=head;
- while(temp->next!=NULL)
- {
- temp=temp->next;
- }
- temp->next=newStd;
- }
- }
- }
- void printInformation()
- {
- std *temp = head;
- printf("\n---------Show Students Information:---------\n");
- int c=1;
- while(temp != NULL)
- {
- printf("\nDisplay student information: #%d\n",c++);
- printf("Name: %s\n",temp-> name);
- printf("ID: %s\n",temp-> id);
- printf("Section: %s\n",temp-> sec);
- printf("Department: %s\n",temp-> dpt);
- temp= temp-> next;
- }
- }
- int main()
- {
- inestData();
- printInformation();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement