void cubes(int n)
{
for (int i=1; i<=n; i++)
cout<<i*i*i<<' ';
}
g_u_e_s_t 0 Newbie Poster
Recommended Answers
Jump to PostHere's a recursive solution that's that's tricky enough that if you turn it in, your teacher will probably realize that you did not write it yourself:
void cubes1(int i, int n) { if (i <= n) { cout << i*i*i << ' '; cubes1(i+1, n); } } …
Jump to Post@arkoenig: I understand that the OP didn't show enough effort towards solving the problem himself that it shouldn't be dignified with an answer. You could just have said so. With all due respect, posting a bad solution and implying that he should make it even worse so that he can …
Jump to Post@arkoenig: I understand that the OP didn't show enough effort towards solving the problem himself that it shouldn't be dignified with an answer. You could just have said so. With all due respect, posting a bad solution and implying that he should make it even worse so that he can …
Jump to PostJust for the record, I agree that the solution is ugly and unnecessary obfuscated, but at least it's fun.
I'm being serious when I say that it's not obfuscated--it illustrates a programming technique that is important in languages that use recursion as a matter of course.
Definition: A function …
All 15 Replies
L3gacy 0 Light Poster
arkoenig 340 Practically a Master Poster
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
arkoenig 340 Practically a Master Poster
frogboy77 73 Posting Pro in Training
arkoenig 340 Practically a Master Poster
frogboy77 73 Posting Pro in Training
Nick Evan 4,005 Industrious Poster Team Colleague Featured Poster
arkoenig 340 Practically a Master Poster
arkoenig 340 Practically a Master Poster
mike_2000_17 commented: Awesome! +2
Nick Evan commented: Cool. Not much of a schemer myself. +16
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
arkoenig 340 Practically a Master Poster
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
Nick Evan 4,005 Industrious Poster Team Colleague Featured Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.