252,162 views
4 votes
4 votes
Help me..and thank you​

Help me..and thank you​-example-1
User Antti Kissaniemi
by
3.1k points

1 Answer

22 votes
22 votes

Answer:

#include <stdio.h>

void spaces(int n) {

for(int i=0; i<n; i++) {

putchar(' ');

}

}

void numbersdown(int n) {

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

putchar('0'+i);

}

}

void numbersup(int n) {

for(int i=1; i<=n; i++) {

putchar('0'+i);

}

putchar('\\');

}

int main(void) {

int number;

printf("Please enter a digit: ");

scanf("%d", &number);

for(int i=number; i>0; i--)

{

spaces(number-i);

numbersdown(i);

numbersup(i);

}

}

Step-by-step explanation:

I deliberately separated the solution into different functions for readability. If needed, the code could be made much more compact.

User Krsnaa
by
2.6k points