C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 3rd, 2010, 12:54 PM
373help_me 373help_me is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 6 373help_me User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 7 sec
Reputation Power: 0
Unhappy General - Programming problem

I need help i write a program that displays a table of integers from 1 to 20 with their squares and cubes. the columns of the table should have appropriate headings....can you plz help me that is wat i have so far -----> feel free to correct me

#include <iostream>
#include <iomanip>

using namespace std;
int main()
{
int i;

for(i = 1; i < 20; i++);
printf ("%8d %8d %8d\n", i, i * i, i * i * i);



return 0;
}

Reply With Quote
  #2  
Old February 4th, 2010, 04:08 PM
DrvC++ DrvC++ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 1 DrvC++ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 37 sec
Reputation Power: 0
Try to treat your table as a matrix

As the title, then the problem is simplified to print multiple arrays in order.

Reply With Quote
  #3  
Old February 4th, 2010, 06:20 PM
MaHuJa's Avatar
MaHuJa MaHuJa is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Dec 2007
Posts: 1,177 MaHuJa User rank is Private First Class (20 - 50 Reputation Level)MaHuJa User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 21 h 27 m 36 sec
Reputation Power: 12
Send a message via Skype to MaHuJa Send a message via XFire to MaHuJa
Are you deliberately trying to confuse a newbie?

Or are you just a generic complicator?

(Or, it might help to read what they're actually posting.)

----

for(i = 1; i < 20; i++);
printf ("%8d %8d %8d\n", i, i * i, i * i * i);

Remove the highlighted ;

I would also suggest staying away from printf(), that's something you use in C. In C++ we have better. It probably won't work with only the headers you've included, either.
Replace that printf call with
cout << i << ' ' << i*i << ' ' << i*i*i << '\n';
__________________
Quote:
Programming by Coincidence
Fred types in some more code, tries it, and it still seems to work. [Then] the program suddenly stops working. [...] Fred doesnít know why the code is failing because he didnít know why it worked in the first place.
Undefined behavior results in: (worst to best)
-Erases your harddisk. Really.
-Appears to work - for now
-Delayed errors/crashes
-Crashes
-Compiler warning

Reply With Quote
  #4  
Old February 4th, 2010, 06:58 PM
373help_me 373help_me is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 6 373help_me User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 7 sec
Reputation Power: 0
Thankz i is for get what language i am write in sometime

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - Programming problem


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap