How do I present output neatly?

In line 7 and 15 I have purposefully put spaces so that the output answers aren't all squished.

How do I ensure that all the answers come in a neat and equal spacing pattern?

I mean, I have heard about <iomanip.h>, but never used it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  	{
	    d=((b*b)- 4*a*c);
    	if(d>=0)
    	{
	    	x=((-b)+sqrt(d))/(2*a);
    		y=((-b)-sqrt(d))/(2*a);
    		cout<<endl<<"The roots of the quadratic equation are:   "<<x<<"   and    "<<y<<".";
    	}
    	else
    	{
    		long double p,q;
    		d=d*(-1);
    		p=-b/(2*a);
    		q=(sqrt(d))/(2*a);
    		cout<<endl<<"The roots of the quadratic equation are:   "<<p<<" + "<<q<<"i    and    "<<endl<<p<<" - "<<q<<"i";
    	}

Last edited on
neat and equal spacing pattern

You could use tabulations to space your output evenly. The char you need to use in this case is '\t'.

For more reference see: https://en.cppreference.com/w/cpp/language/escape
I think you should be seeing the output...
Once I figure out how to do that....
Topic archived. No new replies allowed.