Operation on list - c++ program, C/C++ Programming

Operation on list - c++ program:

Write a program in c to Insert value on list and list iteration.

typedef struct item *node_ptr;

struct item {

                  int element;

                  node_ptr next;

                  }

typedef node_ptr list;

typedef node_ptr position;

 

void main()

{

list head;

 

void  create(list);

void print(list);

head=(list)malloc(sizeof(struct item));

head->next=NULL;

 

create(head);

print(head);

}

 

void create(list head)

{

 position temp;

 char opt;

 

 while (1)

 {

 printf("Enter yuor option\n");

 flushall();

 scanf("%c",&opt);

 

 if(opt=='n'||opt=='N')

 

 return;

 if(head->next== NULL)

 

 head->next=temp=(position)malloc(sizeof(struct item));

 else

 temp=temp->next=(position)malloc(sizeof(struct item));

 temp->next =NULL;

scanf("%d",&temp->element);

}

}

void  print(list head)

 { position temp;

  temp =head->next;

  while (temp  !=NULL)

  {

  printf("%d",temp->element);

  temp=temp->next;

 

 }

 }

Posted Date: 10/19/2012 2:57:45 AM | Location : United States







Related Discussions:- Operation on list - c++ program, Assignment Help, Ask Question on Operation on list - c++ program, Get Answer, Expert's Help, Operation on list - c++ program Discussions

Write discussion on Operation on list - c++ program
Your posts are moderated
Related Questions

Explain Processing A Data File? Mainly data file applications needs that a data file be altered as it is being processed. For instance in an application involving the processin

I have a mini project where I need to write a code .wonder if someone can help me.I already have the forms and webmaster page done just need to code portion

Develop a C++ program that uses a while to determine the gross pay (in Dollars) for each of several employees. The company pays “straight-time” for the first 40 hours worked by eac

i need to do my home work

Question 1 Implement a class stack which simulates the operations of the stack allowing LIFO operations. Also implement push and pop operations for the stack 2 Explain the c


Develop a client and a server for an instant messaging system based on UDP and IPv4


A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation.