Float type output have some issues

Hello,I have some issues with my output with double type.a and b output are always 0x28f8c8 and 0x28f288.Detailed explaination will be very helpful,since I'm just started learning C++,thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

int main(int n)
{
    cin >>n;
    double a[200],b[200],d[200],delta[200];
    for(int i=0;i<n;i++)
        {
          cin >>d[i];
          delta[i] = pow(d[i],2.0) - 4*d[i];
          cout <<fixed << delta[i] << endl;
          if(delta[i]>0)
            {
              a[i] = (-d[i] + sqrt(delta[i])) / 2.0;
              b[i] = (-d[i] - sqrt(delta[i])) / 2.0;
          cout << "Y " << a << " "<< b<< endl ;
            }
          if(delta[i]==0)
            {
             a[i]=b[i]= -d[i]/2;
           cout <<"Y " << a << " "<< b << endl;
            }
           if(delta[i]<0){cout << "N" <<endl;}
        }

    return 0;
}
a and b are whole arrays. You want individual elements, presumably a[i] and b[i]:
cout << "Y " << a[i] << " "<< b[i] << endl ;

No idea why you need arrays at all here.
Last edited on
Oh right,my bad.
Thank you very much ^-^
Topic archived. No new replies allowed.