Hello, Everbody
can anyone help me;
i have to make a program in C
which gives the output like this;
using loops;
output is 1
22
333
4444
55555
4444
333
22
1
Hello, Everbody
can anyone help me;
i have to make a program in C
which gives the output like this;
using loops;
output is 1
22
333
4444
55555
4444
333
22
1
We won't do your homework for you. Post a good try and the errors you're getting, and then maybe we can help you.
Try this:
Code:#include<stdio.h> int home,work;main(){for(home+=49; home<=53; home++){for(work=49;work<=home;work++)putchar(home); puts("");}for (home-=2; home>=49; home--){for (work=49; work<=home; work++)putchar(home);puts("");}}
Dude, come on!!! I suck at this stuff.....but even a person missing their brain should be able to do that.....just read whatever book your supposed to read and you'll figure it out!!!
here is a hint..for loops inside for loops with different conditionals.
You or the forum members?i have to make a program in C
Learn C++ (C++ Books, C Books, FAQ, Forum Search)
Code painter latest version on sourceforge DOWNLOAD NOW!
Download FSB Data Integrity Tester.
Siavosh K C
noodles, giving bad advice or bad code is worse than doing nothing.
After ; or { or } there should always be a newline.
Use tabs or spaces.
Haven't you heard of int main() ?
For without {} braces is a bad idea, especially if you give advice to beginners.
Always initialize your variables.
Use as few global variables as you can.
The program ends and doesn't show anything if you don't put a getchar() or something else there.
Do not use puts("") for getting a newline! Use putchar('\n').
You did so many bad things on 3 lines! Isn't that a record?
Last edited by maxorator; 11-25-2006 at 03:03 AM.
"The Internet treats censorship as damage and routes around it." - John Gilmore
I dunno, I thought noodles answer was quite good.
It produces the result (what the OP asked for), but does it in such a way that the OP really can't use the answer for handing in as homework (what the OP wanted).
Of course, what the OP NEEDS to do if they every want to learn this stuff is actually try and make an attempt at solving the problem rather than reading other peoples answers.
It's all pretty moot anyway since they haven't even bothered to return since posting, so I guess they've already sponged the answer off someone else and is happy for the moment at least. Poor fool, just wait for the next assignment - you know, the one which gets you to the top of the gentle hill and then you see Everest in the distance and the OMG moment hits.
> You did so many bad things on 3 lines! Isn't that a record?
Ever heard of the IOCCC ?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Salem, that is the best reply to a homework thread I have seen in this board. Brilliant.
Double Helix STL
It's an art of doing bad things.Ever heard of the IOCCC ?
"The Internet treats censorship as damage and routes around it." - John Gilmore
At least have the sense to tell the difference between a mistake and code that has been purposefully obfuscated, since we don't exist to hand out grades.