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"); } }