Computer Science, asked by jaiswalvedika240, 1 month ago

Print the pattern

5 5 5 5 5
4 4 4 4
3 3 3
2 2
1​

Answers

Answered by ashnadawra3010
1

Answer:

how to generate pattern above pattern using c i tried this

int i, j, N;

scanf("%d", &N);

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

{

   //Logic to print spaces

   for(j=N; j>i; j--)

   {

       printf(" ");

   }

   //Logic to print numbers

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

   {

       printf("%d ", i);

   }

   for(j=N; j>i; j--)

   {

       printf(" ");

   }

   printf("\n");

}

Explanation:

(‐^▽^‐)

Answered by Oreki
3

\textsf{\large \textbf{Algorithm (Native)}}

  \text{\textemdash \:\: Iterating from 5 to 1 in the outer lo\symbol{111}p.}\\\text{\textemdash \:\: Iterating from 1 to the outer lo\symbol{111}p's counter variable in the inner lo\symbol{111}p.}\\\text{\textemdash \:\: Printing the value of outer lo\symbol{111}p's counter variable in the inner lo\symbol{111}p.}\\\text{\textemdash \:\: Hence, generating the triangle pattern.}

\textsf{\large \textbf{Algorithm (String)}}

  \text{\textemdash \:\: Iterating from 5 to 1 in the outer lo\symbol{111}p.}\\\text{\textemdash \:\: Printing the outer lo\symbol{111}p's  counter variable after concatenating it \textit{i} times.}\\\text{\textemdash \:\: Hence, generating the triangle pattern.}

Attachments:
Similar questions