Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:35:45+00:00 2026-06-09T11:35:45+00:00

I am new to C++, learning it by my self, and I am using

  • 0

I am new to C++, learning it by my self, and I am using the book “C++ how to program – 7th edition” from Deitel. Now, please have a look at the following code

    #include <iostream>
    #include <iomanip>
    #include <cmath>

    using namespace std;

    int main()
    {
        double principle = 1000;
        double amount;
        double rate = 0.05;

        cout << "Year" << setw(21) << "Amount on deposit" << endl;

        cout << fixed << setprecision(2);

        for(int years=1; years<=10; years++)
        {
            amount = principle * pow(1.0+rate,1.0);

            cout << setw(4) << years << setw(21) << amount << endl;
        }
}

When I removed the “fixed” stream manipulator, the output becomes stupid, which means, just ascii letters and numbers. When I insert it, the output comes without any problem. My question is, why is this happening? Is “fixed” mandatory for all the programs which has “double” type outputs? Please help.

And another thing. What are stream manipulators? As a Java developer, I thought these might be some kind of constant variables, but it is not! They are methods? Then why the brackets are not there? Please answer to this question too.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:35:46+00:00Added an answer on June 9, 2026 at 11:35 am

    The output does not “become stupid”: you simply let your output stream choose the format for your floating-point numbers, and it picks scientific notation. This gives you 1e+03 (which means 1*10^3) instead of 1050.00. The use of fixed tells the stream that you do not want scientific notation; you could also use scientific to force the scientific format. Since the precise format depends depends on your application requirements, the choice to use fixed or scientific is ultimately up to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to learning MPI and I coded up the following simple program
Hello to all that read I am self learning C++ from a text book.
I'm new self learning to used Jquery functions and i have no ideas how
So I'm new to Objc-C and I'm just now learning about using @property and
Okay at the moment I my self am new to programming and learning it
When learning new languages such as C++ from PHP, does reading other language snippets
I'm new to learning JSPs and Servlets. I have a Java class which calls
New to wpf and through a learning curve. I have a userControl with a
I am learning iOS. I m using Xcode 4.3.2 , and i have created
I'm new to Rails and i'm currently learning from tutorials from http://ruby.railstutorial.org/chapters/modeling-and-viewing-users-one#top find_by_email works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.