Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Languange : Can someone fix this? Where the console, the output should be displayed as follows: >: Student Record : Students | ID numbers

C Languange : Can someone fix this?

 

Where the console, the output should be displayed as follows:

>: Student Record : Students | ID numbers | ID numbers alex | 9 | BME alok | 98 | BME

 
#include  #include  struct node { char name[50]; int id; struct node *nextptr; }*HeadNode; void createNodeList(int n); void displayList(); int main(){ int n; printf(" Input the number of student :> "); scanf("%d", &n); createNodeList(n); printf("  >: Student Record :  "); displayList(); return 0; } void createNodeList(int n){ struct node *CurrentNode, *PrevNode; int i, id; char name[50]; char programme[30]; for (i=1; i<=n; i++){ CurrentNode = (struct node *)malloc(sizeof(struct node)); if(CurrentNode == NULL){ printf(" Memory can not be allocated."); break; } else{ printf(" Input student name for node %d : ", i); scanf("%49s", CurrentNode->name); printf(" Student ID %s : ", CurrentNode->name); scanf("%d", &id); printf(" Programme (e.g BME) %s : ", CurrentNode->name); scanf("%29s", &programme); CurrentNode->id = id; CurrentNode->nextptr = NULL; if(i==1) HeadNode = CurrentNode; else PrevNode->nextptr = CurrentNode; PrevNode = CurrentNode; } } } void displayList(){ struct node *stNode; if(HeadNode == NULL) printf ("List is empty"); else { stNode = HeadNode; printf("\t%10s | %10s  | %10s ", "Students", "ID numbers", "Programme"); while(stNode !=NULL){ printf("\t%10s | %10d  | %10c ", stNode->name, stNode->id, stNode->programme); stNode = stNode->nextptr; } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions