This is a discussion on A little help please within the C Programming forums, part of the General Programming Boards category; Here is something that I can't figure out... How can I make a program that prints a Number triangle with ...

1. ## A little help please

Here is something that I can't figure out... How can I make a program that prints a

Number triangle with height = b
Example: b=5
Output is
55555
4444
333
22
1

2. What have you tried?

3. Originally Posted by laserlight
What have you tried?
Code:
```counter = 1;
b = 1;
do {
printf("%d\n", counter);
}while (counter <=b);
b++;```
This. It only prints single numbers.

4. Why would you start with a low number if your output is supposed to start with a high number? It's almost as if you don't know how to count backwards. Try Googling "how do I count backwards".

Quzah.

5. Originally Posted by quzah
Why would you start with a low number if your output is supposed to start with a high number? It's almost as if you don't know how to count backwards. Try Googling "how do I count backwards".

Quzah.
Oh.... Sorry bout that. Thank you. Such a genius, (.m^m.)
That didn't helped. That was a practice code. Of course I know how to count.

6. Originally Posted by bummielove
Of course I know how to count.
Not according to any of the code you have posted. How about you try again?

Hint: Start at 5 and count backwards.

Quzah.

7. Originally Posted by quzah
Not according to any of the code you have posted. How about you try again?

Hint: Start at 5 and count backwards.

Quzah.
Code:
``` #include <stdio.h>

int main ()
{

int x = 1, y = 1, b;

printf("What value for b did you enter? ");
scanf("%d", &b);
y = y*b;
while ( y <= b){
printf("%d", x);
y++;
}
{
printf("\n");
x++;
}

return 0;

}```

8. Backwards is sort of a key word here. How do you get from 5 to 4? From 4 to 3? Etc.?

9. Good lord.... try this....
Code:
```#include <stdio.h>

int main (void)
{ int row, col;

for( row = 9; row > 0; row--)
{ for (col = row; col > 0; col--)
printf("%d",row);
printf("\n"); }

return 0; }```
Like the guys said... count BACKWARDS....