home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

C program help ASAP

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2711
Discussions: 200,998, Posts: 2,379,969, Members: 246,365
Old February 21st, 2007, 08:56 PM   Digg it!   #1 (permalink)
Member
 
Join Date: Dec 2004
Location: Va Bch. VA
Posts: 134
C program help ASAP

I'm on my last question of my final:

MUST USE NESTED FOR LOOPS

I need to write a program that accepts 5 integers between 1 & 30 and then print out that number of asterisks.

Sample Output

Enter five numbers between 1 & 30: 1 2 3 4 5

*
**
***
****
*****
__________________
Self built:
Abit AS8, 3.4GHz P4, 2Gig RAM, Radeon 9800, Audigy 2 ZS, 16x DL DVD, Internal SD/XD reader, WD HDD

Last edited by sectshun8 : February 21st, 2007 at 09:09 PM.
sectshun8 is offline   Reply With Quote
Old February 21st, 2007, 11:30 PM     #2 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,552
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
What part of this do you need help on.....
__________________
Signatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
jkrohn is offline   Reply With Quote
Old February 21st, 2007, 11:36 PM     #3 (permalink)
Mobile Member
 
ShuckyD's Avatar
 
Join Date: Apr 2005
Location: S. Central PA
Posts: 3,602
is this a console based app? if so is it C++ or just C?
__________________
Thinkpad T61 14.1" wide | WinXP Pro | C2D T8300 CPU | 3GB DDR2 | 160GB HDD | AGN & WWAN
Lenovo S10 10.2" LED display | 1.6Ghz Atom CPU | 1GB DDR2 | 1.3mp webcam | B/G WiFi | 160GB HDD
ShuckyD is online now   Reply With Quote
Old February 22nd, 2007, 08:40 AM     #4 (permalink)
Senior Member
 
Join Date: May 2003
Location: Aus, Gold Coast :)
Posts: 802
Send a message via ICQ to exally
ok this is off the top of my head
Code:
int x[5];
cin >> x[0];
cin >> x[1];
cin >> x[2];
cin >> x[3];
cin >> x[4];
for(int i=0; i<0; i++) //1 loop
{
for(int j=; j<x[i]; j++)//2nd nested loop
{
cout << "* ";
}
cout << endl;
}
substitute count for printf if u can't use the std - i can't remember the sub for cin - sorry
exally is offline   Reply With Quote
Old February 23rd, 2007, 02:30 PM     #5 (permalink)
Senior Member
 
The Terk's Avatar
 
Join Date: Jul 2002
Location: Texas A&M
Posts: 611
Send a message via AIM to The Terk
Quote:
Originally Posted by exally View Post
substitute count for printf if u can't use the std - i can't remember the sub for cin - sorry

scanf
__________________

The Terk
The Terk is offline   Reply With Quote
Old February 23rd, 2007, 04:12 PM     #6 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,552
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
Quote:
Originally Posted by exally View Post
ok this is off the top of my head
Code:
int x[5];
cin >> x[0];
cin >> x[1];
cin >> x[2];
cin >> x[3];
cin >> x[4];
for(int i=0; i<0; i++) //1 loop
{
for(int j=; j<x[i]; j++)//2nd nested loop
{
cout << "* ";
}
cout << endl;
}
substitute count for printf if u can't use the std - i can't remember the sub for cin - sorry

If this is a question on his final and he has no clue how to do this, you are certinaly not helping him by giving him the code.... Well unless he wants to become a VB programmer that is *hides*

In all seriousness though, don't post solutions to peoples homework/tests. Pseudocode, no problem, but at least make them figure out syntax for themselves, especially when it is as basic as this. Last check this wasn't CheatIMO. (Though it is almost an anagram)

Jkrohn
jkrohn is offline   Reply With Quote
Old February 24th, 2007, 12:00 AM     #7 (permalink)
Senior Member
 
Join Date: May 2003
Location: Aus, Gold Coast :)
Posts: 802
Send a message via ICQ to exally
Quote:
Originally Posted by jkrohn View Post
If this is a question on his final and he has no clue how to do this, you are certinaly not helping him by giving him the code.... Well unless he wants to become a VB programmer that is *hides*

In all seriousness though, don't post solutions to peoples homework/tests. Pseudocode, no problem, but at least make them figure out syntax for themselves, especially when it is as basic as this. Last check this wasn't CheatIMO. (Though it is almost an anagram)

Jkrohn


at his level what good would psuedo code do??? it would probably confuse him more than anything -> if he can't understand that code then there is no hope for him... it is simple create an array, fill the array, use a loop to navigate the array, use the nested loop to output the array data.... atleast i didn't use tab indexing so he atleast has to discover whats going on there.... in this case i was right to give him the code.

plus by glancing at the code there is major error - so if he used the code would have to go through it line by line to discover this error

Last edited by exally : February 24th, 2007 at 12:02 AM.
exally is offline   Reply With Quote
Old February 24th, 2007, 01:26 AM     #8 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,552
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
Quote:
if he can't understand that code then there is no hope for him.

If he can't understand how to even start this question on his final then he needs to be taught something. Giving him code will help him zero. And yes that entire problem IS simple, which is why it is even more alarming he simply asked "how do you do it" which is even more reason to try to teach him the logic behind it and leave the syntax to him.
jkrohn is offline   Reply With Quote
Old February 24th, 2007, 04:02 AM     #9 (permalink)
Senior Member
 
Join Date: May 2003
Location: Aus, Gold Coast :)
Posts: 802
Send a message via ICQ to exally
it is pointless anyway john - he submitted that on 22nd, i answered on the 24th so he would have been finished.
exally is offline   Reply With Quote
Old February 27th, 2007, 10:07 PM     #10 (permalink)
Caveat Emptor
 
Rootstonian's Avatar
 
Join Date: Mar 2005
Location: Out of my mind
Posts: 3,242
Send a message via AIM to Rootstonian
I know it's old, but fun nonetheless Sorry, a little rusty on C++, might not be *perfect*! Didn't put in check for numbers 1 to 30 either

Code:
int i=0, input=0;

while(1) // infinite loop ;)

++i;       // first number
if(i==5) // loop exit
  break;
else {
  cin >> input;
  for(int x=0;x<input;++x)
    cout << '*' << '\n';
}
end-while

Last edited by Rootstonian : February 27th, 2007 at 10:10 PM.
Rootstonian is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
need help ASAP! mista_haqeem Graphics Cards and Displays 4 July 24th, 2006 12:29 AM
Need TV Help ASAP MitaDC General Tech Discussion 1 February 17th, 2006 02:17 PM
What is Better!? Help ASAP!! Crisstina Graphics Cards and Displays 12 May 18th, 2005 10:35 PM
In Need Of Help!!! Asap lildavidxd Technical Support 3 December 29th, 2004 07:04 AM
Need some CC help ASAP Banti IMO Community 0 March 7th, 2002 11:35 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (3100)
Charges against non-tippers dropped.. (22)
Health Care Rationing (17)
Foxconn Blackops x48 MoBo (5)
Nvidia GTX 260 problem (14)
Delete an OS (18)
Laptop with wireless problem. (13)
Wireless Televisions. (12)
windows vista security holes (19)
CPU fan stops spinning randomly (11)
Regular Build (11)
Point and Shoot Camera Suggestions. (9)
[F@H SPAM 11/16/09] ! 1/2 months to.. (41)
windows 7 problem (7)
Recent Discussions
Delete an OS (18)
Outputing 1080p from my PC to my 720p.. (0)
panasonic dmr ez48veb recorder (0)
add ram to existing (3)
Need help getting speakers to work (2)
Nvidia GTX 260 problem (14)
Laptop with wireless problem. (13)
Point and Shoot Camera Suggestions. (9)
Is the PSU I received dead? (16)
FreeAgent drive software not x64 comp.. (1)
Intel 5100 AGN issues fixed yet? (28)
Foxconn Blackops x48 MoBo (5)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (41)
Print spooler problem (17)
Q9650 vs. Q9550 (2)
Desktop Calendar Application (2)
Looking for new motherboard (1)
soundmon.exe (8)
Jedi Academy Problem (3)
Can a page file be "too big".. (1)
Size after cutting 700Mb file is 2.5 .. (0)
windows vista security holes (19)
updating BIOS via winflash, claims fi.. (1)
New Server Configuration Suggestions (0)
cheap gaming laptop? (12)


All times are GMT -4. The time now is 12:39 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28