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
Object Oriented Programming Paradigm: For OOP, Paradigm is a standard set.  The OOP will help to develop software in modules, which will be integrated later as a full packag


Write a algorithm to explain the processof wakingbup in morning

requiredrequiredrequiredrequiredrequiredrequiredrequiredrequired

C Program for FUNCTION OF COUNT THE INTEREST float si(float,float,float); void main() {           float p=0,r=0,n=0,k=0;           clrscr();           printf("E

What is the real function of class - to export data? No, Real purpose of a class isn't to export data. Instead, it's to provide services. Class provides a way to abstract behav

#question.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. For a s

F r i e n dly Function: A class can have public members and private members.   The public member can be used through the class using dot operator.   Where as private me

You are to develop a Clinic System. 1. Identify and briefly explain the objects, classes, methods and attributes for the Clinic System. 2. Draw a use case diagram to represen

write a program that counts the number of occurences of the string in the n-th Padovan string P(n) program in java // aakash , suraj , prem sasi kumar kamaraj college progr