![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Banned
![]() ![]() |
Re: arrays??
What Ooble is saying with
loop from i = 12 to 1 means, loop starts at 1, goes until it equals 12, and increments by 1 each time. If you know even a sliver of C, translating that should be no problem.
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#12 |
|
Newbie
Join Date: Mar 2008
Posts: 7
Rep Power: 0
![]() |
Re: arrays??
well here's my code i dnt know what to do nxt, any suggestions thnx in advanvce...
#include <stdio.h> main() { int b; printf("Enter a value:"); scanf("%d",&b); for (b=b; b>=1; b--) { printf("%d ", b); } getch(); clrscr(); } |
|
|
|
|
|
#13 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 648
Rep Power: 4
![]() |
Re: arrays??
What you've got to do is stop asking useless questions and actually look at a reference on C.
We're here to help your understanding, but not to do your homework for you. Ooble gave you a perfect description of the algorithm to use. Any inability to complete the assignment at this point is just a lack of effort.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#14 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Re: arrays??
Play around with the code below. I haven't tested or compiled, but just trying to give you an idea of what a nested loop would look like. Also, note that reusing the save variable 'b' that's supposed to be your loop limit as a loop iterator is a bad idea.
#include <stdio.h>
main()
{
int b, i, j;
printf("Enter a value:");
scanf("%d",&b);
for (i=b; i>=1; i--)
{
for (j = i; j >=1; j--)
{
printf("%d ", j);
}
}
getch();
clrscr();
} |
|
|
|
|
|
#15 |
|
Newbie
Join Date: Mar 2008
Posts: 7
Rep Power: 0
![]() |
Re: arrays??
thank you very much for the big help OpenLoop jst added a "printf("\n");" to get the exact output... i++ for you...
![]() here's the code... u've made ![]() #include <stdio.h> main() { int b, i, j; printf("Enter a value:"); scanf("\n%d",&b); for (i=b; i>=1; i--) { printf("\n"); <------------------------------JST ADDED THIS TO GET THE CORRECT OUTPUT... for (j = i; j >=1; j--) { printf("%d ",j); } } getch(); clrscr(); } |
|
|
|
|
|
#16 |
|
Banned
![]() ![]() |
Re: arrays??
Oh goody. He can Ctrl+V. Any bets on what his first test's mark will be?
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| joining associative arrays | MiKuS | PHP | 2 | Sep 6th, 2007 3:20 AM |
| Confusion With Pointers and Arrays | JawaKing00 | C | 10 | Sep 14th, 2006 8:33 AM |
| Arrays or Vectors? | can342man | C++ | 2 | Apr 20th, 2006 4:57 PM |
| Arrays in PHP | MrMan9879 | PHP | 6 | Jan 12th, 2006 10:18 PM |
| Arrays | Gunman | C++ | 17 | Oct 20th, 2005 7:11 AM |