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
The Special Pointer 'this' When various instances of a class come into existence, it naturally follows that each instance has its own copy of member variables. If this were not

store the name of the political parties and the corresponding votes in two lists of equal length. access the lists is provided by two methods, each of which creates an interator th

find the area of a curve y=f(x) between x=a and x=b integrate f(x) between limits a and b   #include float start_point, /* GLOBAL VARIABLES */

A: C++, unlike only about every other language with exceptions, is extremely accomodating while it comes to what you can throw. Actually, you can throw anything you akin to. That b

Write a recursive function recursiveMin that takes an integer array, a starting subscript and an ending subscript as arguments, and returns the smallest element in the array. The f

Program is to append the contents of one file to another: void main()    {   clrscr();   fstream file1,file2;   char st1[13],st2[13];/* 13 because a filename canno

A string is said to be "Beautiful"€, if it contains only non repetitive alphabets

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Write a program which incorporates a function named compute and which is used to calculate the area and circumference of a circle. Use the main function for inputs and outputs.

C Program for FUNCTION  OF COMPOUND INTEREST float ci(float,float,float); void main() {           float p=0,r=0,n=0,k=0;           clrscr();           printf("EN