I'll try to get this as simple as possible. The problem is fairly simple.

long double a=100000000;

Well, the output this shows is "1e+08"

I do not want the output to be in exponential form. Rather, I want it to be printed as "100000000".

What shall I do?

Thnaks in advance.

Use std::fixed.

cout << std::fixed << a;

Hi...Thanks for a response.

But, I am getting the following errors:-

Type qualifier 'std' must be a struct or class anme in function main()

Statement misisng in function main()

The errors occur when the program is as follows:-


void main()

	 long double a=100000000.0;

Which compiler are you using?

using namespace std;

int main()
  long double a=100000000.0;
  return 0;

Use CodeBlocks compiler.

I'm using Turbo C++ 4.5

From where can I download codeblocks compiler?

I'm using Turbo C++ 4.5

From where can I download codeblocks compiler?


Include iomanip header file and use setiosflags(ios::fixed,ios::adjustfield) manipulator.

Mark this thread as Solved if you get solution.

"cout" doesn't support any specific formatting.

cout supports a lot of formatting options, and you can add more. It is a very flexible design, much more flexible than printf. But the design is very verbose and convoluted compared to printf.

You can use printf defined under stdio. Use a corresponding qualifier.

I agree. For most of the formatting jobs that printf can do, it is shorter and probably faster that cout. Which makes more sense here when printing fixed format with no precision?

#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main()
    long double value = 100000000.0;

    // chained modifiers on cout
    cout << fixed << setprecision(0) << value << '\n';

    // printf with a format string
    printf("%.0f\n", value);

The cout line is a little over twice as long, and it is not as obvious what the output will look like by skimming the code. I think formatting macros embedded in an output string are easier to figure out, but not having to type all of that extra junk is a big win.

Thanks for help everyone. Well, the problem si that I don't know how a printf function works. A link to guide on using printf would be highly appreciated.

Ok, Ok, Everyone screwed me. But, I felt that printf would be easier to format.

"printf" is often easier. unfortunately, that the way you worded your response was incorrect.
Those guys just can't handle different opinions.
This question has already been answered. Start a new discussion instead.