C

Alternate Repeat Pattern

40
0
Home C Alternate Repeat Pattern

The program must accept a positive even integer N as the input. The program must print the desired pattern as shown in the Example Input/Output section.


Boundary Condition(s) : 2 < N < 100

Input Format:
The first line contains the positive even integer N.

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

Example Input/Output 1:

Input
6

Output
1666666
2255555
3334444

Example Input/Output 2:

Input
4

Output:
14444
22333

include<stdio.h> 
#include<stdlib.h>
int main()
{
	int n; 
	scanf("%d",&n);
 
	for (int i=1;i<=n/2;i++)
	{
		for (int j=1;j<=i;j++)
		{
			printf("%d",i);
		}

		for (int k=1;k<=n-i+1;k++)
		{
			printf("%d",n-i+1);
		}

		printf("\n");
	}
}
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 *