New Member FAQ | Forums | Earn Revenue | Posting Guidelines | Help Topics


ResourcesPractice TestsAsk ExpertsQuestion PapersJobsStudy in UKUniversitiesCollegesCoursesSchoolsTraining


My Profile

Awards & Gifts


Active Members
TodayLast 7 Daysmore...





Evaluation of PostFix Expression


Posted Date:     Total Responses: 0    Posted By: pankaj agarwala   Member Level: Silver   Points/Cash: 3   


### C Program of Evaluation of PostFix Expression




#define MAX 50
#include
#include
#include
float stack[MAX];

int top=-1;
void push(float val)
{
if(top==MAX-1)
return ;
stack[++top]=val;
}
float pop()
{
if (top==-1)
return -9.9;
else
return stack[top--];
}

void main()
{
clrscr();
char post[20];
int i=0;
float A,B,C;
printf("\n Enter expression");
gets(post);
while(post[i]!='\0')
{
if(isdigit(post[i]))
push(post[i]-48);
else if(post[i]!=32)
{
A=pop();
B=pop();
if(post[i]=='*')
C=B*A;
else if(post[i]=='/')
C=B/A;
else if(post[i]=='+')
C=B+A;
else if(post[i]=='-')
C=B-A;
push(C);
}
i++;
}
printf("\n result=%f",stack[0]);

getch();
}




Project Feedbacks


No feedbacks found. Be the first to respond...

Post Feedback
You must Sign In to post a feedback.
Next Project: Conversion of infix expression to postfix expression
Previous Project: Implementation of Quick Sort

Return to Project Index

Post New Project


Related Projects

Subscribe to Email
  • Get Jobs by Email
  • Forum posts by Email
  • Articles by Email



  • website counter

    Online Membersbenson gomez
    Ashish Kumar
    Iti Tyagi
    Sakshi Sood
    dks
    Arvind
    siva
    sathishkumar
    Shiyas
    Kamlesh. M. Dhurve
    Saraswathi
    More...



    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    AdSense Revenue Sharing sites   Advertise   Talk to Tony John
    ISC Technologies, Kochi - India
    2006 - 2012 All Rights Reserved.