Really a silly question but this solution evades me.
As you can see, double digits move the entire line one digit to the left, how can I correct this? I presume setw() is needed.1 + 1 = 2
10 + 1 = 11
2 + 2 = 4
Really a silly question but this solution evades me.
As you can see, double digits move the entire line one digit to the left, how can I correct this? I presume setw() is needed.1 + 1 = 2
10 + 1 = 11
2 + 2 = 4
How do you want it to look?Or?Code:1 + 1 = 2 10 + 1 = 11 2 + 2 = 4Code:1 + 1 = 2 10 + 1 = 11 2 + 2 = 4
Code:1 + 1 = 2 10 + 1 = 11 2 + 2 = 4
link to setw()
Is the problem with using setw() or the largest number of digit not known?
source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense
I can't get this sorted.
The above gives me the following:Code:cout << setw( 7 ) << num1 << " - " << num2 << setw( 5 ) << "= ";
I make this change which still doesn't work:Code:4 - 3 = x 14 - 14 = x 6 - 2 = x
Code:cout << right << setw( 7 ) << num1 << " - " << num2 << setw( 5 ) << "= ";I'd like the subtraction and equal signs in a row in all cases with 1 to two digits but don't know how to get it like that. Help would be appreciated.Code:10 + 11 = x 6 + 1 = x
Code:10 + 10 = x 9 + 1 = x 1 + 11 = x
Last edited by cyberCLoWn; 06-23-2004 at 01:07 PM. Reason: Slight modification..
try
Code:cout<<setw(7)<<num1<<" - "<<setw(7)<<num2<<" = ";
Got it.
Code:cout << right << setw( 7 ) << num1 << " -" << setw( 3 ) << num2 << setw( 5 ) << "= ";
Why? You are using a constent for setw's parameter on a fixed length string....Code:<< setw( 5 ) << "= ";
Guess I see what you mean. This was just a quick refresher project to get me back into the swing of C++. Have not really had a chance to touch it in a while.
Thanks anyhow Thantos