Q:

write c program to generate following pattern

0

write c program to generate following pattern

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

#include <stdio.h>
int main() {
   int i, j, rows;
   printf("Enter the number of rows: ");
   scanf("%d", &rows);
   for (i = rows; i >= 1; --i) {
      for (j = 1; j <= i; ++j) {
         printf("%d ", j);
      }
      printf("\n");
   }
   return 0;
}

Output:

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming Exercises With Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
<< Write a program to demonstrate the use of malloc a...