It does not work

It´s work.

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
#include <iostream>

using namespace std;
//Declaración de datos en coma flotante(F. Prototipo)
float sumar(float,float);
int main ()//Función principal
{
float sumando1, sumando2;

cout<<"sumando1:"<<sumando1<<"\n"<<endl;
cin>>sumando1;
cout<<"sumando2:"<<sumando2<<"\n"<<endl;
cin>>sumando2;

float sumando1, sumando2, resultado;
resultado=sumar(sumando1,sumando2);

cout <<"Resultado:"<<resultado<<"\n"<<endl;
}

//Declaración de la coma flotante (Invocar)
float sumar(float x,float y)
{
float z;
z=x+y;
return z;
}
Last edited on
You're missing some stream operators between the strings in lines 10, 12 and 18.

Also, what's a loat ?

Also, line 22 has a semicolon at the end, which you don't want.
On lines 10 and 12 any particular reason to print the memory addresses of variables sumando1, sumando2 which, incidentally, have also been re-declared on line 15 which I don't think is needed
Line 22: x, y should be const qualified and you don't need lines 24-5, just return x+y; is sufficient and to maintain symmetry with the argument types the function could also return by reference though for POD it doesn't make any difference
Your compiler's error messages should have highlighted most of these ...
Topic archived. No new replies allowed.