Pages

E-mail us at prgms4starters@gmail.com for any queries or to share your programs. Please mention the program definition in the subject line.

In case you need help in finishing a program, do mention "incomplete pgm" in the subject line. Our team of experts will do their best to help you.

Click the link to follow this page for updates and reminders: FOLLOW THIS SITE

You can also visit our Facebook page by clicking HERE

**don't forget to participate in the polls at the bottom of the page

Friday, November 5, 2010

student details using linked list in vc++

#include<iostream>
#include<conio.h>
#include<process.h>
#include<string>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

char reg[10];
struct student{
char regno[10];
char name[20];
char class1[10];
int marks[3];
student *link;
}*temp,*head,*t,*x;

int find()
{ int str=0;
t=head;
x=head;
cout<<"\n\nPlease enter the Regno to find : "; cin>>reg;
if(head!=NULL)
{
do
{
str=strcmpi(t->regno,reg) ;
if (str==0) //||t->regno==reg)
{
return 1;
}
x=t;
t=t->link;
}while(t->link!=NULL);

str=strcmpi(t->regno,reg) ;
if (str==0) // ||t->regno==reg)
{
return 1;
}

}
else
return 0;


}


void add()
{
int choice;
clrscr();
cout<<"\n-= Add Student =-"; cout<<"\n1. Add In Beginning"; cout<<"\n2. Add In Between"; cout<<"\n3. Add At End"; cout<<"\nSelection : "; cin>>choice;

temp=new student;


switch(choice)
{
case 1:

if(head==NULL)
{
head=temp;
temp->link=NULL;
}
else
{
temp->link=head;
head=temp;
}
break;
case 2:
if(find())
{
temp->link=t->link;
t->link=temp;
}
else
{cout<<"\nInvalid Regno!!"; free (temp); goto lab; } break; case 3: temp->link=NULL;
t=head;
while(t->link!=NULL)
t=t->link;
t->link=temp;
break;
default:
{cout<<"\nInvalid Selection"; free (temp); goto lab; } } cout<<"\nPlease enter the student Regno : "; gets(temp->regno);
cout<<"\nPlease enter the student Name : "; gets(temp->name);
cout<<"\nPlease enter the student Class : "; gets(temp->class1);
cout<<"\nPlease enter the Marks Of The Subject 1: "; cin>>temp->marks[0];
cout<<"\nPlease enter the Marks Of The Subject 2: "; cin>>temp->marks[1];
cout<<"\nPlease enter the Marks Of The Subject 3: "; cin>>temp->marks[2];
lab:
}

void display()
{
system("cls");
cout<<"\nProgress Report"; if(find()) { cout<<"\nRegno :"<regno;
cout<<"\nName :"<name;
cout<<"\nClass :"<class1;
cout<<"\n--------------------------"; cout<<"\n\nMarks"; cout<<"\nSubject 1 : "<marks[0];
cout<<"\nSubject 2 : "<marks[1];
cout<<"\nSubject 3 : "<marks[2];
}
else
cout<<"\n Invalid Reg No"; } void del() { if(find()) { if(head==t) { head=t->link;
free(t);

}
else if(t->link==NULL)
{
x->link=NULL;
free(t);
}
else
{
x->link=t->link;
free(t);
}
}
else
cout<<"\nInvalid Reg No"; } void main() { system("cls"); int choice; head=NULL; while(1) { system("cls"); cout<<"\n-={Student Details Using Singly Linked List}=-"; cout<<"\nPlease Select an Operation To Perform"; cout<<"\n1. Add a Student"; cout<<"\n2. Display Student Details"; cout<<"\n3. Delete a Student"; cout<<"\n4. Exit"; cout<<"\nSelection : "; cin>>choice;

switch(choice)
{
case 1:
add();
break;
case 2:
display();
break;
case 3:
del();
break;
case 4:
exit(0);
break;
default:
cout<<"\nInvalid Selection"; } getch(); } }

No comments:

Post a Comment

We have noticed that 20% of our visitors are still using internet explorer. For a better and faster surfing experience we recommend that you switch to either Google Chrome or Mozilla Firefox. We cannot provide you the downloads but here are the links to sites where you can download them from

Google Chrome - click here to go to site

Mozilla Firefox - click here to go to site

Where are you from

Do you think this site was helpful

Should we put up more C or C++ programs