Skip to content

send otp.py - #55

Merged
spiderxm merged 1 commit into
spiderxm:masterfrom
Ananya02850:master
Oct 2, 2021
Merged

spiderxm merged 1 commit into
spiderxm:masterfrom
Ananya02850:master

Conversation

@Ananya02850

Copy link
Copy Markdown
Contributor

#include<stdio.h>
#include<string.h>
#define SIZE 20
char STACK[SIZE];
int top=-1;
void push(char item)
{
if(top==SIZE-1)
printf("\nSTACK IS OVERFLOW");
else
{
top++;
STACK[top]=item;
}
}
void pop()
{
if(top==-1)
printf("\nunderflow");
else
top--;
}
int main(void)
{
char exp[SIZE];
int len,i;
printf("\nenter the expression");
scanf("%s",exp);
len=strlen(exp);
for(i=0;i<len;i++)
{

	if(exp[i]=='(' || exp[i]=='{' || exp[i]=='[')
	{
		push(exp[i]);
		continue;
	}
	else if(exp[i]==')' || exp[i]=='}' || exp[i]==']')
	{
		if(exp[i]==')')
		{
			if(STACK[top]=='(')
			{
				pop();
			}
			else
			{
				printf("\nUNBALANCED PARENTHESIS");
				return 0;
			}
		}
		else if(exp[i]=='}')
		{
			if(STACK[top]=='{')
			{
				pop();
			}
			else
			{
				printf("\nUNBALANCED PARENTHESIS");
				return 0;
			}
		}
			else if(exp[i]==']')
			{
				if(STACK[top]=='[')
				{
					pop();
				}
				else
				{
					printf("\nUNBALANCED PARENTHESIS");
					return 0;
				}
			}
		}
	}

if(top!=-1)
printf("\nUNBALANCED PARENTHESIS");
else
printf("\nBALANCED PARENTHESIS");
return 0;

}

@spiderxm
spiderxm merged commit a50a39b into spiderxm:master Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants