New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



postfix evaluation using Linked list in c programming


Posted Date:     Total Responses: 0    Posted By: R V Vinod Babu   Member Level: Silver   Points/Cash: 2   


#include
#include
#include
#define null 0
typedef struct post
{
int data;
struct post *next;
}node;
node *newnode, *temp,*head;
void alloc(int);
void main()
{
char a[20];
int i,v1,v2,res,k;
head=null;
clrscr();
printf("\nEnter the postfix expression using linked list:");
//gets(a);
while((a[i]=getchar())!='\n')
{
if(isdigit(a[i]))
{
k=a[i]-48;
if(k>0&&k<=9)
{
alloc(k);
}}
else
{
temp=head;
v2=temp->data;
head=head->next;
free(temp);
temp=head;
v1=temp->data;
head=head->next;
free(temp);
switch(a[i])
{
case '+': res=v1+v2;
break;
case '-': res=v1-v2;
break;
case '*': res=v1*v2;
break;
case '/': res=v1/v2;
break;
default:printf("\nEnter an valid postfix expression");
}
alloc(res);
}
i++;
}
printf("Result is:%d",head->data);
getch();
}
void alloc(int k)
{
newnode=(node *)malloc(sizeof(node));
newnode->next=null;
newnode->data=k;
newnode->next=head;
head=newnode;
}


Project Feedbacks


No feedbacks found. Be the first to respond and make money from revenue sharing program.

Post Feedback
You must Sign In to post a feedback.
Next Project: Simulation of Flow solving Navier Stokes Equation.
Previous Project: ServerTech

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.