Hello everyone this is my code and I just help I managed to correct the first 3 questions but the rest I am still getting errors.
Below is the all question :
Complete the provided main()
program with statements to accomplish each of the following. In each case you must use the appropriate I/O stream manipulators to produce the appropriate output wherever possible.
- Output first first as an integer value, followed by a space, then in its written form.
- Output second as a base ten value, followed by a space, then as a hexadecimal
- value, followed by a space, then as an octal value. Make sure the appropriate base indicator prefix is shown in the output.
- Output third.
- Output fourth with four digits, with the sign shown at the left, and the value right aligned. The decimal point must also appear.
- Output fourth with four significant figures.
- Output fifth with seven significant figures. (Note: use left alignment here)
- Output fifth with three digits to the right of the decimal point.
- Output third.
- Output fourth with two digits to the right of the decimal point.
- Output sixth with no decimal portion showing
- Output fourth with eight digits to the right of the decimal point.
- Output sixth with six digits.
Here is my code so far :
#include <iostream>
#include <iomanip>
using namespace std;
int
main0()
{
bool first;
int second;
long third;
float fourth;
float fifth;
double sixth;
cout << "Enter bool, int, long, float, float, and double values: ";
cin >> first >> second >> third >> fourth >> fifth >> sixth;
cout << endl;
cout << noboolalpha << first;
cout << " ";
cout << boolalpha << first << endl;
cout <<left << dec << showbase;
cout << second;
cout << " ";
cout << internal << hex << showbase;
cout << second;
cout << " ";
cout <<right << oct <<showbase;
cout << second << endl;
cout << third<< scientific<< endl;
cout <<left << setw(4)<<fixed<< fourth <<endl;
cout <<setprecision(4)<< fourth <<endl;
cout <<left<<setw(7)<< fifth << endl;
cout <<right<<setprecision(3)<< fifth;
cout <<third<<endl;
cout <<right<<setw(2)<<fourth<<endl;
cout << fixed<<sixth<< endl;
cout << right << fixed<<setprecision(8)<< fourth<< endl;
cout <<left<<showpoint <<setprecision(6)<<sixth;
// ***** Solution ends here ****
cin.get();
return 0;
}
I answered 4-6:
Good luck with the rest.