Insert item in stack

Advertisements

Stack in C Stack POP Operation

Push Operation

In case of stack Insertion of any item in stack is called push. In stack any item is inserted from top of the stack, When you insert any item in stack top will be increased by 1.

push operation in stack

Algorithm for push

  1. Initialization, set top=-1
  2. Repeat step 3 to 5 until top<Max size-1
  3. Read, item
  4. Set top=top+1
  5. Set stack[top]=item
  6. Print "stack overflow"

Example of Push Item in Stack

	
  void push()
  {
   int item;
  if(top==size-1)
  {
  printf("\n stack is full");
  }
  else
  {
  top=top+1;
  printf("\n\n Enter element in stack: ");
  scanf("%d",&s.item);
  s.stack[top]=s.item;
  }
  }

Stack in C Stack POP Operation

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements