The result doesn't show...

Ok, Hi, thanks for reading my code. Ok this Function its suppose to calculate the power by 2 or the square root of a value, depending of the entry code.
As you can see, its part of the definition


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Calcula el cuadrado de un valor.
	float MisFunciones::calculo(float val)
	{

		if(codigo == 0)
		{
		   return  pow(valorReal, 2);
		}

		else 
			if(codigo == 1)
			{
			  return sqrt(valorReal);
			 
			}

        else 
             cout << "-1"; ; 

	}


As in main

1
2
3
4
5
6
7
8
9
10
 cout << "\n\n\tEntre el codigo de entrada:";
	  cin >> code;
      miFunA.setCodigo(code);

      cout << "\n\n\tEntra el valor a calcular:";
      cin >> valor;
      miFunA.setValorReal(valor);

      cout << "\n\n\t El resultado es:";
      miFunA.calculo(valor);


You input the code, the value to calculate and the object will call the calculo function, displaying: El resultado es: . depending of the entry code and value should be a result but its not showing the result as you see:

[url]http://img231.imageshack.us/img231/7271/doesntshowwhyax6.gif

Why? Thanks by the way !

Anyone?

PSPMAN90


EDIT: Ok, this is Ironic! I myself, when I post this here, I get the point, that I wasn't doing this:

cout << "\n\n\t El resultado es:" << miFunA.calculo(valor) << endl;

Now they show! OMG!
My bad! Thanks by the way!
Pleas don't delete this post in case of me getting crazy and on need of professional assistance.
Thanks!

Last edited on
That image is way too small...anyway, I think the problem is you are passing it the float "val" but you are using a different value when computing the root/square. You are also not outputting the value at all, you need cout << in front of miFunA.calculo(valor);
Your method calculo() is not outputting the data, just returning it.

cout << miFunA.calculo(valor);

However, you will want to return -1; instead of couting it in the function body.

Edit: I don't have any problems with image size...
Last edited on
Topic archived. No new replies allowed.