Computer Science, asked by shreyashshreya222, 9 months ago

A String is said to be valid if it contains a pair of parenthesis having text/alphabets
enclosed such as (TY) and the String is said to be invalid if it contains nested parenthesis
such as (Y(UP)).
e.g.: “SUN (A(X) RISE) BEGINS FROM (RT) EAST” is an ‘Invalid’ string because
in this string nested parenthesis are present, but “SUN (A) RISE BEGINS FROM (RT)
EAST” is a ‘Valid’ string because there is no nested parenthesis.
Write a program to read a Sentence and convert it is in capitals. Check the validity of
Sentence. If the String is valid, then display the given String omitting the portion
enclosed in parenthesis otherwise, display a message “Sorry, an invalid String”.
Test your program for the given sample data and also some other data.
Input : SUN (A) RISE BEGINS FROM (RT) EAST
Output : SUN RISE BEGINS FROM EAST
Input : SUN (A(X) RISE) BEGINS FROM (RT) EAST
Output : “Sorry, an invalid String”.

Answers

Answered by jogisingh64
0

Answer:

I DONT NO THE Answer Bro

Similar questions