In C programming language write a function that takes an integer
n as input and prints the following pattern on the screen:
1 (n times)
2 (n-1 times)
.n (1 time)
For example, if n was 5, the function should print
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
#include <stdio.h> void numberPattern(int n); int main() { int n; printf("Enter a value for n: "); scanf("%d", &n); numberPattern(n); return 0; } void numberPattern(int n) { int i, j; for (i = n; i >= 1; --i) { for (j = 0; j < i; ++j) { printf("%d ", n - i + 1); } printf("\n"); } }
Get Answers For Free
Most questions answered within 1 hours.