Click here to Skip to main content
13,558,939 members
Rate this:
Please Sign up or sign in to vote.
See more:
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. Refer to the sample output below as a guide for proper output alignment.

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. (Must be left-aligned)
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.

You must start your coding by using exactly the following program. You may not modify it, except to add the required code between the Solution starts, and Solution ends comments.
#include <iostream>
#include <iomanip>
using namespace std;
    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;

// ***** Solution starts here ****

// ***** Solution ends here ****

    return 0;

SAMPLE PROGRAM OUTPUT (assume user inputs values shown in bold):
Enter bool, int, long, float, float, and double values:
1 69 1464878 6443.39 -7.273 -6443.39
1 true
69 0x45 0105
+ 6443.
Posted 20-Feb-13 10:54am
Updated 20-Feb-13 10:56am
Marco Bertschi 20-Feb-13 17:04pm
please do not take this as an insult - are you trying to get us to finish your homework?
Oh and by the way: It seems like you forgot to set the user inputs' fond to bold (right after you souce block).
Edit: We are trying to help you with homework if you can show us the effort you have done until now and can show us a paticular example where an error does occur.
I only can start explaining thcode lines which you already have submitted:
cout << "Enter bool, int, long, float, float, and double values: ";
Writes the sentence between the "" out to the console.

cin >> first >> second >> third >> fourth >> fifth >> sixth;
Reads the variables' values from the console - starting with variable "one" and ending with "six".

I can maybe help you if you tell me what you have tried until now and explain me why you are stuck.

Marco Bertschi
Sarah Trattner 20-Feb-13 17:25pm
No I just need some clarification on cout << setprecision....etc. The professor I have takes zero time to explain anything for us newbies and I feel like; even though I'm hardware/software inclined that programming is going to kick my <<bleep>> if I don't get some extra help.
Marco Bertschi 20-Feb-13 17:36pm
You can always get extra help on codeproject as long as you follow some basic rules:
- Be kind
- Tell us what you have done by now
- Tell us why you are stuck
- Pinpoint where you need the help (in your case: Can someone explain me the cout<< and cin >> setpession in this code sample?)
- You can submit questions about the C++ progamming language at the corresponding forum:
The experts are there and you usually can get an answer much faster than herre in the Q & A section

About the cin / cout thing: Maybe this link below is going to help you:

And we stand fully behind every one whos teacher is a complete moronic <otherinsulthere> who cannot explain stuff to his students.
Valery Possoz 20-Feb-13 17:34pm
What a silly assignment! I don't think that using riddles to teach programming is very clever... lewax00 solution points you articles showing how to format outputs.
Marco Bertschi 20-Feb-13 17:38pm
Slow down, it is a beginners tutorial. She will se lewax00' solution by herself.
Sarah Trattner 20-Feb-13 17:46pm
Thank you to everyone. I will try the link and the forum as well. Valery, I agree, on our Professor rating site he ranks at a "1" for his communication and teaching skills. I now see why. I literally was in tears yesterday when he attempted to explain this assignment. Apparently I am supposed to already know C++ before taking the class (wow).
Sarah Trattner 20-Feb-13 17:47pm
@Marco, I never take anything as an insult unless it starts off with "You are a....".
Thank you for your time and suggestions.
CHill60 20-Feb-13 18:42pm
Sarah ... Good Luck, keep working hard. Hope you work your way through the ... erm ... less than helpful teachers. Head Up! :-)

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04-2016 | 2.8.180515.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100