# Thread: Need Help With My Loops??

1. ## Need Help With My Loops??

Hello All,
I am in a c..programming class at my college.. We were given a problem..and its been bothering me now for 3 days..I can't figure out how to get this program to work.. I could simply write 7 identical for loops to get the desired output, but that is cheesy, like using multiple printf statements to get the desired output..
Here is my problem? And my code. Can someone at least give me a clue..as to what i'm doing wrong.. thanks..
Code:
```/*Write a program that would draw a number diagram like this:

7 7 7 7 7 7 7
6 6 6 6 6 6
5 5 5 5 5
4 4 4 4 4
3 3 3 3
2 2 2
1 1
0

0
1 1
2 2 2
3 3 3 3
4 4 4 4 4
5 5 5 5 5 5
6 6 6 6 6 6 6
7 7 7 7 7 7 7 7
*/

#include <stdio.h>
int main()
{
/* Declaring Variables */
int number =7;
int i;
int j;
int sum=7;
/* While Loop for 7 Lines of Output */
while(number <= 7)
{

/*  For Loop for Printing out numbers on Line */
for(i=0; i<j; ++i)
printf("%d", sum);

/* After For Loop Decrease Sum by 1 */
/* Go Down One Line */
sum=sum-1;
printf("\n");
}
}```

2. Your loop is counting down from 7, so don't stop once it's bigger than seven, continue while it's bigger than 0 (or -1 depending on how you write it).

Quzah.

3. Well I need 7 Lines of output.. So I figured i would need a loop that counts down from 7??
7777777
666666
55555
4444
333
22
1
0
I'm trying to do this program in sections..I'm working on the first count down..before i even think about the bottom part..

4. Can anyone help me with my loop problem? I'm kind of jammed up for time.. Already late on this assignment..

5. I didn't say don't make it count down. I said stop checking to see if it's less than 7. Obviously it's less (or equal to) than seven! You start at seven and count down! Why wouldn't it be less than 7? I said stop when you reach zero! Read damnit!

Quzah.