#include <iostream>
#include<conio.h>
using namespace std;
void main()
{
double *p,*q,*m,x1,x2;
void sumpo(double*, double*, double*);
p=&x1;
q=&x2;
cout << "Enter the doubles";
cin >> x1 >> x2;
sumpo( &p, &q, &m);
cout << *p << *q << *m;
_getch();
}
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>
2
#include<conio.h>
3
using namespace std;
4
int main()
5
{
6
double *p,*q,*m,x1,x2,sum;
7
void sumpo(double *, double *, double *);
8
p=&x1;
9
q=&x2;
10
m=∑
11
cout << "Enter the doubles";
12
cin >> x1 >> x2;
13
sumpo( &p, &q, &m);
14
cout << *p << *q << *m;
15
_getch();
16
}
17
void sumpo( double* ptr_p, double* ptr_q, double* ptr_m)
18
{
19
*ptr_m=*ptr_p +*ptr_q;
20
}
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