How to add the numbers between nodes
example. input 1*2+3 first 2 and 3 will add and it will become 1 5 nodes then 1 * 5 = 5 then node will becaome 5 only
this is my sample program
#include<stdio.h>
#include<stdlib.h>
#define p printf
#define s scanf
struct node
{
int data;
struct node *link;
};typedef struct node *nodepointer;
void push(nodepointer &top,int num)
{
nodepointer newnode;
newnode=(nodepointer)malloc(sizeof(struct node));
newnode->data=num;
newnode->link=top;
top=newnode;
}
void display(nodepointer top)
{
if(top==NULL)
{
p("\nNothing to display");
}
else if(top!=NULL)
{
while(top->link!=NULL)
{
p("\n%i",top->data);
top=top->link;
}
p("\n%i",top->data);
}
}
void pop(nodepointer top)
{
int sum;
nodepointer after;
nodepointer before;
if(top==NULL)
p("\nList is empty...");
else
{
while(after->link!=NULL)
{
before=after;
after=after->link;
sum=before->data+after->data;
}
}
}
main()
{
nodepointer top;
top=NULL;
int number;
int choice;
char operators;
do
{
p("\n[1].Push");
p("\n[2].Display");
p("\n[3].Add operator");
p("\nKey choice: ");
s("%i",&choice);
switch(choice)
{
case 1:
p("\nEnter number: ");
s("%i",&number);
push(top,number);
break;
case 2:
display(top);
break;
case 3:
p("\nenter operator");
fflush(stdin);
s("%c",&operators);
if(operators=='+')
pop(top);
break;
}
}while(1==1);
system("pause");
}