Parenthesis Pattern

39
0
Home Programs Parenthesis Pattern

The program must accept a string $ as the input. The program must print the desired pattern as shown in the Example Input/Output section.

Boundary Condition(s):
1 < Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The lines containing the desired pattern as shown in the Example Input/Output section.

Example Input/Output 1:
Input:
SkillRack
Output:
(S)killRac(k)
S(k)illRa(c)k
Sk(i)llR(a)ck
Ski(l)l(R)ack
Skil(l)Rack

Example Input/Output 2:
Input:
hide
Output:
(h)id(e)
h(i)(d)e

#include<stdio.h>
#include<stdlib.h>

int main()
{
	char a[1000]; 
	scanf("%s",a); 
	int x=0,y-strlen(a)-1;
	while(x<=y)
	{
		for(int i=0;i<strlen(a);i++)
		{
			if(i==x||i==y) 
				printf("(%c)",a[i]); 
			else 
				printf("%c",a[i]);
		} 
		printf("\n");
		x++;
		y--;
	}
}
Hephzibai
WRITTEN BY

Hephzibai

Hephzibai is a driven third-year student at St. Joseph's Institute of Technology, specializing in Computer Science and Engineering. With a keen interest in data science and also in fullstack.
One of my greatest strengths lies in my programming skills, which I've honed through countless hours of practice and participation in coding challenges. Platforms like Skillrack, HackerRank, and others have been my playgrounds, where I've tackled a wide range of problems with creativity and determination.

Leave a Reply

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