C programming

Sunday, January 18, 2009

#include #include #include #include typedef struct { char nam[40]; int roll; }rec; struct student { rec std; student *next; }info,*nptr,*tptr,*list; void newnode(char nm[],int r) { nptr=new student; for(int i=0;i<40;i++) nptr->std.nam[i]=nm[i]; nptr->std.roll=r; nptr->next=NULL; } void link() { if(list==NULL) { list=nptr; tptr=nptr; } else { tptr->next=nptr; tptr=nptr; } } void showinfo() { student *curptr; curptr=list; int j=1; while(curptr!=NULL) { printf("\nName (%d) : %s\nRoll No. : %d",j,curptr->std.nam,curptr->std.roll); curptr=curptr->next; j++; } } void information(int inf) { printf("\n\nEnter students information\n"); for(int i=0;istd.roll!=r) list=list->next; if(list->next==NULL) { delete(list->next); list->next=NULL; } else { list->next=list->next->next; delete(list->next); list->next=NULL; } } void menu() { int s,nw,droll; printf("\n\n* * Menu * * \n"); printf("\nShow 1"); printf("\nAdd 2"); printf("\nSearch 3"); printf("\nDelete 4"); printf("\nExit 5"); printf("\n\nEnter : "); scanf("%d",&s); switch(s) { case 1 : printf("\n\nStudents information\n"); showinfo(); getch(); menu(); break; case 2 : printf("\nHow many information you want to add : "); scanf("%d",&nw); information(nw); menu(); break; case 3 : break; case 4 : printf("\nEnter roll no of student which you want to delete : "); scanf("%d",&droll); Delete(droll); menu(); break; case 5 : exit(0); } } void main() { clrscr(); int ns; printf("\nEnter number of students : "); scanf("%d",&ns); list=NULL; information(ns); menu(); getch(); }

0 comments:

Visitors

PlugIn.ws - Free Hit Counter, Web Site Statistics, Traffic Analysis

  © Blogger template Leaving by Ourblogtemplates.com 2008

Back to TOP