I have already viewed this thread but it does not account for using negative numbers if i use setfill( '0' ).
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//Code
int num1;
cin >> num1;
cout << setw(5) << setfill( '0' ) << num1 << endl;
return 0;
}
Using this method if I enter a "5" it will display as "00005". But if I enter a -5 it will display as "000-5"
How can I fix it so that the out put will be "-0005" ?