Check Matching Parantheses without Stack C Program

C Program To Check Matching Parantheses without Stack

Learn How To Check Matching Parantheses without Stack in C Programming Language. This Matching Parantheses C Program takes a String as an Input from the User. The String contains the Algebraic Expression.

The Matching Parantheses Algorithm is very simple. It counts the number of Opening Parantheses and Closing Parantheses. If both are equal, then the Parantheses are Matching in the Expression, else the Algebraic Expression is an Unbalanced Expression. This Parantheses Matching Problem is also famously known as Onion Peeling Problem. However this algorithm only focuses on the count of opening and closing parantheses. It does not check the exact parantheses. This can be done using Stack as the Data Structure instead of a String Array.

Must Read: C Program To Check Balanced Parantheses in an Expression

This Code traverses the Expression String and counts the number of Opening and Closing Brackets. The Parantheses used in an Algebraic Expression are:

Opening Parantheses / Brackets: { [ (

Closing Parantheses / Brackets: } ] )


Must Read: C Program To Reverse a String using Stack Data Structure

C Program For Checking Matching Parantheses in an Expression without Stack

Must Read: C Program To Create Own Header Files

Output

Check Matching Parantheses without Stack in C Programming using For and If Else Loop

If you have any compilation errors or doubts in this C Program To Find if Parantheses are matching or Not without using Stack Data Structure, let us know about in the Comment Section below. Find more about Stack Data Structure on cs.cmu.edu.


Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

One thought on “Check Matching Parantheses without Stack C Program

  • September 13, 2016 at 10:28 am
    Permalink

    This is the best explanation and code I found for checking if paranthese are matching or not. This is such an easy code.

    Reply

Join The Discussion