The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 21, 2019, 12:52:26 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: C++ Programming Question. How do you calculate Squares and Cubes?!?  (Read 4092 times)
Stella Richards
n00b
*
Offline Offline

Posts: 1


View Profile
« on: May 04, 2009, 04:45:55 AM »

Hi,

I am trying to write a program for my Intro to C++ Course to calculate Squares and Cubes but I am unsuccessful. The printout is supposed to be aligned in a chart, 3 columns, with rows 1-10. Below is part of the program, but even this will not compile properly:

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main ()

{

cout << setw(6) << 1 << setw(6) << pow(1 , 2) << setw(6) << pow(1 , 3) << endl;

return 0;

}


Any idea's where I am going wrong? Sorry if this is such a broad question. I have been working on this for hours and I am just having trouble getting the concepts of C++ down.

Thanks!!!
Logged

No links in signatures please
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: May 04, 2009, 06:00:42 AM »

Compiling on Linux or Windows?

My C++ ain't what it should be, but I've been known to hack some C from time to time.
Logged

hai
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #2 on: May 04, 2009, 03:35:36 PM »

Makes no difference if windows or linux.
need to use "fill"
http://www.deitel.com/articles/cplusplus_tutorials/20060218/cplusplus_streamformatstates_streammanipulators_Page4.html

Sounds like u are doing some sort of retarded C++ programing course where instructor is anal and is more concerned about the output as opposed to does the program work. Probably because the retard is too stupid to actually look at the program.
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!