4
I did a basic function of squaring (exercise of a book), and I use a variable named aux
and the use to calculate the power value squared, but the compiler claims that aux
is not initialized, I would like to understand why and how to solve this problem.
/*fazer uma função que calcule e retorne o valor de um número ao quadrado*/
#include <stdlib.h>
#include <iostream>
using namespace std;
double square (double);
int main ()
{
double x;
cout << "Digite um numero:\n";
cin >> x;
system ("clear");
cout << "O numero " << x << " elevado ao quadrado eh: " << square (x) << "\n";
}
double square (double x)
{
int i;
double aux;
for (i = 0; i < x; i++)
{
aux = aux + x;
}
return aux;
}
How are you compiling? which compiler are you using? The variable is in use yes.
– Maniero
Hi @bigown I use Visual Studio 2015 in windows and the terminal in linux here a photo of the 'error list' of visual studio http://i.imgur.com/nr7G0Z6.png
– Leonardo V. De Gasperin