Sep 11, 2015 at 7:40pm UTC
Hi guys please fix this issue :), Thanks. something going wrong at cout. Thanks a lot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
using std::ios;
#include <iomanip>
using std::setiosflags;
using std::hex;
using std::oct;
using std::dec;
int main()
{
//Print integer 40000 left justified in a 15-digit field.
cout << setiosflags( ios::left ) << setw( 15 ) << 40000 << '\n’;//
//Print 200 with and without a sign.
cout << setiosflags( ios::showpos ) << 200 << setw( 4 ) << ' \n’
<< resetiosflags( ios::showpos ) << 200 << ’\n’;
//Print the decimal value 100 in hexadecimal form preceded by 0x.
cout << setiosflags( ios::showbase ) << hex << 100 << '\n’;
//Print 1.234 in a 9-digit field with preceding zeros
cout << setiosflags( ios::fixed | ios::showpoint ) << setw( 9 )
<< setfill( ’0’ ) << setiosflags( ios::internal ) << 1.234 << ' \n’;
return 0;
}
Last edited on Sep 11, 2015 at 7:41pm UTC
Sep 11, 2015 at 7:57pm UTC
Yeah Miinipaa,Thanks. I fixed that issue , but its showing some errors while running at the first cout.
Sep 11, 2015 at 8:09pm UTC
Here you go, Thanks :)..!!
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
using std::ios;
#include <iomanip>
using std::setiosflags;
using std::hex;
using std::oct;
using std::dec;
int main()
{
// unsigned integer 40000 left-justified in a 15-digit field.
cout << setiosflags( ios::left ) << setw( 15 ) << 40000 << '\n';
//200 with and without a plus sign
cout << setiosflags( ios::showpos ) << 200 << setw( 4 ) << '\n'
<< resetiosflags( ios::showpos ) << 200 << '\n';
//100 in hexadecimal form preceded by 0x.
cout << setiosflags( ios::showbase ) << hex << 100 << '\n';
//1.234 in a 9-digit field with preceding zeros.
cout << setiosflags( ios::fixed | ios::showpoint ) << setw( 9 )
<< setfill( '0' ) << setiosflags( ios::internal ) << 1.234 << '\n';
return 0;
}
Sep 11, 2015 at 8:13pm UTC
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// unsigned integer 40000 left-justified in a 15-digit field.
cout << setiosflags( ios::left ) << setw( 15 ) << 40000 << '\n';
cout << setw(15) << setiosflags(ios::fixed | ios::left) << setprecision(3)<< 12.3456 << '\n';
//200 with and without a plus sign
cout << setiosflags( ios::showpos ) << 200 << setw( 4 ) << '\n'
<< resetiosflags( ios::showpos ) << 200 << '\n';
//100 in hexadecimal form preceded by 0x.
cout << setiosflags( ios::showbase ) << hex << 100 << '\n';
//1.234 in a 9-digit field with preceding zeros.
cout << setiosflags( ios::fixed | ios::showpoint ) << setw( 9 )
<< setfill( '0' ) << setiosflags( ios::internal ) << 1.234 << '\n';
return 0;
}
Thanks I fixed it.. I appreciate the quick response from this forum, I hope one day I can help the people back :)..!!
Sep 11, 2015 at 8:23pm UTC
Line 19,31: setw needs std:: namespace qualification or explicit using statement.
Line 24: resetiosflags needs std:: namespace qualifier
Line 32: setfill needs std:: namespace qualifier.
Line 32: 0 still has the wrong single quotes.