Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have two programs in C++ below that I pasted that completed both screenshots(

ID: 3739891 • Letter: I

Question

I have two programs in C++ below that I pasted that completed both screenshots( first screenshot goes with the first program I pasted below), I need help on combining both those programs into one C++ program please.

Description: Part I: Implement stack using array representation Your program should support normal stack operations as learned from the class Part II: Make use of your own stack implementation (from Part I) to check any program for balanced symbols: .0.0 Example: t0;, 0);: legal (G, (O;: illegal Write your program using C++, it reads the string of symbols from a program file (e.g.. program.c) and print "legal" or "illegal" as the result.

Explanation / Answer

//Programname.cpp

/*

CPP programe to check balanced expression or not based on paranthsis (),{},<>,[]

*/

//header files required to program

#include<iostream>

#include<stack>

#include<string>

using namespace std;

// function defination for checking two characters are opening or closing

bool function1(char opening,char closing)

{

if(opening == '(' && closing == ')') return true;

else if(opening == '{' && closing == '}') return true;

else if(opening == '[' && closing == ']') return true;

else if(opening == '<' && closing == '>') return true;

return false;

}

//function defination for given expression have paranthsis (),{},<>,[],if availbale push the character to stack

bool BalncingFunction(string exp)

{

stack<char> S;

for(int i =0;i<exp.length();i++)

{

if(exp[i] == '(' || exp[i] == '{' || exp[i] == '[' || exp[i] == '<')

S.push(exp[i]);

else if(exp[i] == ')' || exp[i] == '}' || exp[i] == ']' || exp[i] == '>')

{

if(S.empty() || !function1(S.top(),exp[i]))

return false;

else

S.pop();

}

}

return S.empty() ? true:false;

}

int main()

{

/*Code to test the function BalncingFunction*/

string exp;

cout<<"Enter an exp: "; // input expression from STDIN/Console

cin>>exp;

if(BalncingFunction(exp))

cout<<"Balanced ";

else

cout<<"Not Balanced ";

}

Output :

<html><html>

Balanced