Showing posts with label pop. Show all posts
Showing posts with label pop. Show all posts
Friday, February 13, 2015
C Program for Array Representation of Stack Push Pop and Display
What is Stack?
Stack is a LIFO (last in first out) structure. It is an ordered list of the same type of elements. A stack is a linear list where all insertions and deletions are permitted only at one end of the list. When elements are added to stack it grow at one end. Similarly, when elements are deleted from a stack, it shrinks at the same end.
Also Read: C++ program to perform a PUSH operation on a dynamically allocated stack
Also Read: Menu Driven C Program to Perform Insert, Display and Delete Operations on a Singly Linked List (SLL)
Below I have written a C program that performs push, pop and display operations on a stack. It is implemented using 1-D array.
![C Program for Array Representation of Stack [Push] C Program for Array Representation of Stack [Push]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgrDi-0dGSvjIQcDb-y52kguyUrjwP4fMBAisMflEC5J1GRiA_IpoRrceGjPuV5GA7RWBYA9AvfNyenFhDKNHgYsWhRL46izZZhWZ_xHCGcRlp7ShwWTfFtCHrTfF1_soh87jC0D6gQbYW/s1600/C+Program+for+Array+Representation+of+Stack+%255BPush%255D.jpg)
![C Program for Array Representation of Stack [Display] C Program for Array Representation of Stack [Display]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlUfs3tAbfklvsF7L49-s7IwJYvxoF0-A-T1iPspItapfFrVCMaZb3YZmxPvzPIYh0uWyxqm9BTMYvtcfVgk6WdscvbZitzGkokEWPDzneLnR2M2SJ_9GKO47673WnR-op-8A-SFUlvrGT/s1600/C+Program+for+Array+Representation+of+Stack+%255BDisplay%255D.jpg)
#include<stdio.h>
#include<conio.h>
#include<process.h> //for exit()
#include<stdlib.h> //for system("cls")
#define MAX 5 //Maximum number of elements that can be stored
int top=-1,stack[MAX];
void push();
void pop();
void display();
void main()
{
int ch;
while(1) //infinite loop, will end when choice will be 4
{
system("cls"); //work in windows, for other OS change it to system("clear")
printf("*** Stack Menu ***");
printf("
1.Push
2.Pop
3.Display
4.Exit");
1.Push
2.Pop
3.Display
4.Exit");
printf("
Enter your choice(1-4):");
Enter your choice(1-4):");
scanf("%d",&ch);
switch(ch)
{
case 1: push();
break;
case 2: pop();
break;
case 3: display();
break;
case 4: exit(0);
default: printf("
Wrong Choice!!Press any key....");
Wrong Choice!!Press any key....");
getch();
}
}
}
void push()
{
int val;
if(top==MAX-1)
{
printf("
Stack is full!!Press any key....");
Stack is full!!Press any key....");
getch();
}
else
{
printf("
Enter element to push:");
Enter element to push:");
scanf("%d",&val);
top=top+1;
stack[top]=val;
printf("
Press any key....");
Press any key....");
getch();
}
}
void pop()
{
if(top==-1)
{
printf("
Stack is empty!!Press any key....");
Stack is empty!!Press any key....");
getch();
}
else
{
printf("
Deleted element is %d
Press any key....",stack[top]);
Deleted element is %d
Press any key....",stack[top]);
top=top-1;
getch();
}
}
void display()
{
int i;
if(top==-1)
{
printf("
Stack is empty!!Press any key....");
Stack is empty!!Press any key....");
getch();
}
else
{
printf("
Stack is...
");
Stack is...
");
for(i=top;i>=0;--i)
printf("%d
",stack[i]);
",stack[i]);
printf("
Press any key....");
Press any key....");
getch();
}
}
Wednesday, January 21, 2015
Hard Rest ALCATEL ONE TOUCH 4010x T POP Smartphone
Hard Rest ALCATEL ONE TOUCH 4010x T POP
how to hard reset Alcatel one touch smartphone ?

Hard reset your smartphone Alcatel one touch T-POP 4010x in case of "forgot pattern lock",forgot user lock "or Gmail account with few simple steps.
Turn off your Smartphone.
Press and hold Volume Up button
Press power button.
Phone will be booted into Recovery mode.

Use Volume Up and Down button to select option.
Select Wipe data and press power button to enter.
Delete all user data.

You may also like to read :
Hard reset ZTE Sanfrancisco
Subscribe to:
Posts (Atom)