EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

When a call is made to a new function all the variables local to the calling routine need to be saved, otherwise the new function will overwrite the calling routine variables. Similarly the current location address in the routine must be saved so that the new function knows where to go after it is completed.

Recursive Function to Find Factorial

int fact(int n)

{

int S; if(n==1)

return(1); else

S = n * fact( n โ€“ 1 );

return(S)

}

Balancing the Symbols

  • Compilers check the programs for errors, a lack of one symbol will cause an error.
  • A Program that checks whether everything is balanced.
  • Every right parenthesis should have its left parenthesis.
  • Check for balancing the parenthesis brackets braces and ignore any other character.

Algorithm for balancing the symbols

Read one character at a time until it encounters the delimiter `#’.

Step 1 : – If the character is an opening symbol, push it onto the stack.

Step 2 : – If the character is a closing symbol, and if the stack is empty report an error as missing opening symbol.

Step 3 : – If it is a closing symbol and if it has corresponding opening symbol in the stack, POP it from the stack. Otherwise, report an error as mismatched symbols.

Step 4 : – At the end of file, if the stack is not empty, report an error as Missing closing symbol. Otherwise, report as balanced symbols.

E.g. Let us consider the expression ((B*B)-{4*A*C}/[2*A]) #

Empty stack, hence the symbols the balanced in the given expression.

Example for unbalanced symbols:

Other Courses

NoSQL

Cloud computing

Power BI

Function Calls in Data Structures

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer