Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 23rd, 2008, 12:39 PM   #11
Sane
Banned
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,101
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is offline   Reply With Quote
Old Mar 23rd, 2008, 2:02 PM   #12
FengLing
Newbie
 
Join Date: Mar 2008
Posts: 7
Rep Power: 0 FengLing is on a distinguished road
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();
}
FengLing is offline   Reply With Quote
Old Mar 23rd, 2008, 3:08 PM   #13
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 648
Rep Power: 4 Jessehk is on a distinguished road
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!
Jessehk is offline   Reply With Quote
Old Mar 23rd, 2008, 3:11 PM   #14
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
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();
}
OpenLoop is offline   Reply With Quote
Old Mar 23rd, 2008, 10:29 PM   #15
FengLing
Newbie
 
Join Date: Mar 2008
Posts: 7
Rep Power: 0 FengLing is on a distinguished road
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();
}
FengLing is offline   Reply With Quote
Old Mar 23rd, 2008, 10:35 PM   #16
Sane
Banned
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,101
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is offline   Reply With Quote
Old Mar 24th, 2008, 4:12 AM   #17
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Re: arrays??

Oh joy. Next time, I don't think I'll be helping quite so much.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:55 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC