New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



linked list


Posted Date:     Total Responses: 0    Posted By: Dhananjoy Chakraborty   Member Level: Gold   Points/Cash: 3   


# include
# include
struct link
{
int data;
struct link *next;
};
int i,x=0;
struct link *start=NULL,*p,*node;
void create()
{
char ch;
i=1;
node=start;
node->next = (struct link* ) malloc(sizeof(struct link));
node = node->next;
/*first location is created and node is now holding the address of the first location. */
printf("\n Enter value for node: %d: ",i);
scanf("%d", &node->data);
fflush(stdin);
node->next = NULL;
printf("\n Enter choice--'n' for break: ");
ch = getche();
while(ch != 'n')
{
i=i+1;
node->next = (struct link* ) malloc(sizeof(struct link));
node = node->next;
printf("\n Enter value for node: %d: ",i);
scanf("%d", &node->data);
node->next = NULL;
printf("\n Input choice n for break: ");
ch = getche();
}
printf("\n Total nodes = %d\n", i);
}
void dis()
{
node=start->next;
while(node)
{
printf("%d\n",node->data);
node=node->next;
}
}
void del()
{
char c;
printf("\nWant to delete the first node (y/n):-");
c=getche();
if(c=='y')
{
x++;
node=start->next;
p = start;
/*external pointer start is holding the address of the first node while the other pointer p is storing NULL */
p->next=node->next;
free(node);
}
else // else block of if(c=='y')
printf("\nYou are not interested in deleting the first node.");
if (x!=0)
{
printf("\n After deleting last node list is as follows\n");
node=start->next;
while (node)
{
printf(" %d", node->data);
node = node->next;
}
}
}
void main()
{
clrscr();
create();
printf("\nPresent position of the linked list before deletion:-\n");
dis();
del();
getch();
}


Project Feedbacks

Author: abhijeetMember Level: SilverRevenue Score: 1 out of 5
good code


Post Feedback
You must Sign In to post a feedback.
Next Project: linked list
Previous Project: linked list

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.