C programming

Tuesday, January 13, 2009

#include #include #include #include typedef struct { char nam[40]; int roll,year,term; char disp[10]; float gpa; }abc; struct student { abc def; student *next; }info,*nptr,*tptr,*list; void newnode(char nm[],int r,char d[],int y,int t,float g) { nptr=new student; for(int i=0;i<40;i++) nptr->def.nam[i]=nm[i]; nptr->def.roll=r; for(int j=0;j<10;j++) nptr->def.disp[j]=d[j]; nptr->def.year=y; nptr->def.term=t; nptr->def.gpa=g; 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 k=1; while(curptr!=NULL) { printf("\nName (%d) : %s\nRoll No. : %d\nDiscipline %d : %s ",k,curptr->def.nam,curptr->def.roll,k,curptr->def.disp); printf("\nYer = %d\nTerm=%d",curptr->def.year,curptr->def.term); printf("\ngpa=%f",curptr->def.gpa); curptr=curptr->next; k++; } } void information(int inf) { printf("\n\nEnter students information\n"); for(int i=0;idef.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