Stack using C++ programmijng language please Write a program to input an arithmetic expression, then 1. Match nested brackets found the expression, if they are matched correctly proceed to step 2. 2. Evaluate the expression. Please not that the operands of the expression may contain more than one digit. the cin of the arithmetic expression is :: ((5+(6/2*3)-2)+1)= you can use this function also ::: struct node { int data; node *next; node(int d,node *n=0) { data=d; next=n; } }; class stack { node *topp; public: stack(); void push(int el); bool pop(); int top(); bool top(int &el); //~stack(); //void operator=(stack &o); //stack(stack &o); }; stack::stack() { topp=0; } void stack::push(int el) { topp=new node(el,topp); } bool stack::pop() { if(topp==0) return false; node *t=topp; topp=topp->next; delete t; return true; } int stack::top() { if(topp!=0) return topp->data; } bool stack::top(int &el) { if(topp==0) return false; el=topp->data; return true; }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question
100%

Stack using C++ programmijng language please 

Write a program to input an arithmetic expression, then

1. Match nested brackets found the expression, if they are matched correctly proceed to step 2.
2. Evaluate the expression.

Please not that the operands of the expression may contain more than one digit.

the cin of the arithmetic expression is ::

((5+(6/2*3)-2)+1)=

you can use this function also ::: 

struct node

{ int data; node *next;

node(int d,node *n=0)

{ data=d; next=n; }

};

class stack

{

node *topp;

public: stack();

void push(int el);

bool pop();

int top();

bool top(int &el);

//~stack();

//void operator=(stack &o);

//stack(stack &o); };

stack::stack()

{ topp=0; }

void stack::push(int el)

{ topp=new node(el,topp); }

bool stack::pop()

{ if(topp==0)

return false;

node *t=topp;

topp=topp->next;

delete t;

return true; }

int stack::top()

{ if(topp!=0)

return topp->data; }

bool stack::top(int &el)

{ if(topp==0)

return false;

el=topp->data;

return true; }

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage