Computer Science, asked by prathm2281, 9 months ago

Pattern III
Write a program to print the following pattern.
Sample Input:

5

Sample Output:

1
2*2
3*3*3
4*4*4*4
5*5*5*5*5
5*5*5*5*5
4*4*4*4
3*3*3
2*2
1

Answers

Answered by ajinkyabiyani
0

Answer:

#include<stdio.h>

int main()

{

 int i,j,n;

 for(i=1;i<=n;i++)

 {

   for(j=1;j<=i;j++)

   {

     if(j<i)  

       printf("%d*",i);

     else  

       printf("%d",i);

   }

   printf(" \n");

 }

 for(i=n;i>=1;i--)

 {

   for(j=1;j<=i;j++)

   {

     if(j<i)  

       printf("%d*",i);

     else  

       printf("%d",i);

   }

   printf(" \n");

 }  

 return 0;

}

Explanation:

Answered by poojan
11

Language used: Python Programming

Program:

n=int(input())

l=[]

for i in range(1,n+1):

   row=(str(i)+'*')*i    #making each row as string

   l.append(row[:-1])    #leaving last extra '*'

   print(row[:-1])

for i in l[::-1]:         #reverse the list so that we can print from the back.

   print(i)

Input:

5

Output:

1

2*2

3*3*3

4*4*4*4

5*5*5*5*5

5*5*5*5*5

4*4*4*4

3*3*3

2*2

1

Learn more:

1. Write a program to print the following pattern.

https://brainly.in/question/11917943

2. Write a program to display prime fibonacci numbers from 100 to 1000 in java

https://brainly.in/question/18378925

Attachments:
Similar questions