Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

i have a error function should have a prototype

#include
#define MAX 100
void push(int);
int pop();
int top=-1,f=0,i;
int stack[MAX];
void main()
{
char post[100],x;
int value, a,b;
clrscr();
printf("Enter the Postfix Expression....");
gets(post);
for( i=0;(x=post[i])!='';i++)
{
if(isdigit(x))
{
push(x -'0');
}
else
{
a=pop();
b=pop();
value=perform(x,a,b);
push(value);
}
}
gets(post);
for(i=0;(x=post[i])!='';i++)
{
if(isdigit(x))
{
push(x=0);
}
else
{
a=pop();
b=pop();
value=perform(x,a,b);
push(value);
}
}
printf("The value of the postfix expression is :%d
",stack[top]);
getch();
}

int perform(char y,int m, int n)
{
int k;
switch(y)
{
case '+':k=n+m;
break;
case '-':k=n-m;
break;
case '*':k=n*m;
break;
case '/':k=n/m;
break;
case '^':k=pow(n,m);
break;
}
return(k);
}
void push(int item)
{
if(top==MAX)
{
printf("overflow
");
return;
}
else
{
top=top+1;
stack[top]=item;
}
return;
}
int pop(int item)
{
if(top==-1)
{
printf("underflow
");
return;
}
else
{
item=stack[top];

top=top-1;
return item;
}
}

Comments

  • abhi6784abhi6784 Member Posts: 6
    Hi,

    For pop function this is the prototype you use:
    int pop();

    and this is the function definition:
    int pop(int item)

    Compiler dint get the prototype of the pop function you define. Try using this as prototype:
    int pop(int);

    -Abhishek Agarwal
    http://tecwing.com
Sign In or Register to comment.