Create a program that would display the following. (for loop) create also the functions Example output: Enter a value for N: 5 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1
Here it is : #include<stdio.h> #include<stdlib.h> int main() { /* c taken for columns */ int i, j, c = 9, m, k; for (i = 1; i <= 5; i++) { /* k is used for spaces */ for (k = 1; k <= c; k++) { printf(" "); } for (j = 1; j <= i; j++) { printf("%2d", j); } for (m = j - 2; m > 0; m--) { /* %2d ensures that the number * is printed in two spaces * for alignment */ printf("%2d", m); } printf("\n"); /* c is decremented by 2 */ c = c - 2; } system("pause"); } NB : I didn't write the program, I just found it so I copy it for you here. Good luck!
Join our real-time social learning platform and learn together with your friends!