 |
|
 |
Home : C/C++
Name : Stack routines stck.c Description : implements stack routines for integers.A file reqd. in the exprerssion evaluator.
Code :#include <stdio.h>
char stack[25];
int top=-1;
void push (char);
char pop ();
int isempty();
float ex (int);
void push (char i) {
top=top+1;
stack[top]=i;
}
char pop (){
char i;
i=stack[top];
top=top-1;
return i;
}
int isempty (){
int i;
if (top==-1) i=1;
else i=0;
return i;
}
float ex (int i) {
float e=1;
if (i<0)
while (i!=0){
{ e=e/10;
i=i+1;
}
}
else
while (i!=0)
{ e=e*10;
i=i-1;
}
return e;
}
|
|
 |