Answer to Question #153550 in C for joy

Question #153550
Write a program to store your name, ID, SSC Grade, HSC Grade using linked list and display it.
1
Expert's answer
2021-01-04T03:37:06-0500
#include<stdlib.h>
#include<string.h>
#include<stdio.h>

struct Student
{
    int ID;
    char name[100];
    char SSC_Grade[100];
   char HSC_Grade[100];
    struct Student *next;
    
}* head;


void insert(int ID, char* name, char* SSC_Grade, char* HSC_Grade)
{
    
    struct Student * student = (struct Student *) malloc(sizeof(struct Student));
    student->ID=ID;
    strcpy(student->name, name);
strcpy(student->SSC_Grade,SSC_Grade);
strcpy(student->HSC_Grade,HSC_Grade);
    student->next = NULL;
    
    if(head==NULL){
    
        head = student;
    }
    else{

        student->next = head;
        head = student;
    }
    
}



void display()
{
    struct Student * temp = head;
    while(temp!=NULL){
        
        printf("ID Number: %d\n", temp->ID);
        printf("Name: %s\n", temp->name);
        printf("Phone: %s\n", temp->SSC_Grade);
        printf("Phone: %s\n", temp->HSC_Grade);
        temp = temp->next;
        
    }
}

int main()
{

   head = NULL;
 
   


insert(2456,"paul","A.","B.");
display();

    return 0;






}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS