Balanced Parenthesis1

Sir,
I think the logic i have applied is correct but its not following the correct if else statements and
Seccondlly I wanted to know that when i was doing if(braces.top()==’{’)
this expression was not being evaluated but else condition was evalueated

when i replaced == witn = the if condition was evaluated but the body was not bein evaluated.

#include
#include<stdio.h>
#include
using namespace std;

int main()
{
stack braces;
string exp;
getline(cin,exp);
//cout<<exp;
int i=0;
while(exp[i]!=NULL)
{
//cout<<exp[i]<<endl;

    if(exp[i]=='('||'['||'{')
    {
        braces.push(exp[i]);
    }
    
     if(exp[i]==')')
    {
        if(braces.top()='(')
        braces.pop();
        else
        {
            cout<<"NO";
            return 0;
        }
    }
    if(exp[i]==']')
    {
        if(braces.top()='[')
        braces.pop();
        else
        {
            cout<<"NO";
            return 0;
        }
    }
    if(exp[i]=='}')
    {
        if(braces.top()='{')
        {
           
            braces.pop(); 
        }

        else
        {
            cout<<"NO";
            return 0;
        }
    }
    //cout<<braces.top()<<", "<<endl;  
    i++;
}
braces.pop();
cout<<braces.top();
if(braces.empty())
cout<<"YES";
else
cout<<"NO";
return 0;

}

Plz send your code by saving on ide

https://ide.codingblocks.com/s/103937 this is the Link

You are somewhere using a wrong approach, try using this approach ,
for(int i=0;input[i]!=’\0’;i++)
{
char ch=input[i];
if(ch==’(’ || ch==’[’ || ch==’{’)
{
s.push(ch);
}
else
if(ch==’)’)
{
if(!s.empty() && s.top()==’(’)
{
s.pop();
continue;
}
else
{
return false;
}
}

Try to modify your code as per this