Fix this code please and correct my mistakes.thanks

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
Your closing character in '\n' is not an apostrophe at all: http://puu.sh/k7Ryy/7bfa4db33f.png
Yeah Miinipaa,Thanks. I fixed that issue , but its showing some errors while running at the first cout.
Did you fix all those issues? Each '\n' had that issue.

its showing some errors
Whech erors exactly? Also post your updated code.
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;

}
#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 :)..!!
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.

Topic archived. No new replies allowed.