#include <iostream>
using namespace std;
void main()
double *p,*q,*m,x1,x2;
void sumpo(double*, double*, double*);
cout << "Enter the doubles";
cin >> x1 >> x2;
sumpo( &p, &q, &m);
cout << *p << *q << *m;
void sumpo( double* ptr_p, double* ptr_q, double* ptr_m)
*ptr_m=*ptr_p +*ptr_q;
Any wrong with the program?Thank you
firstly it does not compile.
have you tried to compile it yourself?

secondly this:
void sumpo(double*, double*, double*);

you should not put function declarations inside your main function.

and can you use code tags please? :)

edit: you also have not initialised m..
Last edited on
As I said before you must use int main(); not void main();
1#include <iostream>
3using namespace std;
4int main()
6 double *p,*q,*m,x1,x2,sum;
7 void sumpo(double *, double *, double *);
8 p=&x1;
9 q=&x2;
10 m=&sum;
11 cout << "Enter the doubles";
12 cin >> x1 >> x2;
13 sumpo( &p, &q, &m);
14 cout << *p << *q << *m;
15 _getch();
17void sumpo( double* ptr_p, double* ptr_q, double* ptr_m)
19 *ptr_m=*ptr_p +*ptr_q;
Last edited on
sorry,i forget to initiate m.But my program still cannot run.
read my post again.

and read mats post again.
Last edited on
Topic archived. No new replies allowed.