1.

Print the following pattern in c program5 4 3 2 14 3 2 13 2 1211Sample testcasesInput 1Output 15Enter the number of rows:5 4 2 14 3 2 13 2 12 11​

Answer»

Answer:

This is the required C program for the question.

#include

int main () {

int i,j,n;

PRINTF("Enter number of rows - ");

scanf("%d",&n);

printf("Here is your pattern.\n");

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

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

printf("%d ",j);

printf("\n");

}

return 0;

}

ALGORITHM:

  1. START.
  2. ACCEPT the number of rows(n).
  3. Iterate outer loop in range - i = n to 1.
  4. Iterate inner loop in the range j = ito 1.
  5. Print the value of j.
  6. Print a new line after displaying the row.
  7. STOP.

See the attachment for output .



Discussion

No Comment Found