Hi there,
Im having some trouble writing a basic program in C++ to multiply two integers, the problem is with the formatting that I cant get right....
The necessary format would be:
99
* 999
-----
98901
(All of the numbers above should be aligned to the right, except the multiplication sign which should remain on the left side)
This is just what I need it to show on the end screen.
Remember, I am a beginner, so here's what I have right now
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <iomanip>
usingnamespace std;
int main () {
int a = 99, b = 999, sum = a * b;
cout <<setw(5);
cout << a <<endl;
cout <<setw(5);
cout << b <<endl;
cout <<setw(5) <<setfill('-') <<endl;
cout <<setw(5);
cout << sum <<endl;
return 0;
}
Im sure im putting the setw and setfill in the wrong places. But im just really struggling with the formatting aspect of C++.