#include <iostream>
#include <string>
#include <cstdlib>
usingnamespace std;
void square(double);
int main()
{
double num;
num = 123.456;
cout << "\n" << " the square of num is" <<square(num);
cout << "\n" << "the current value of num is " << num;
}
void square(double x)
{
return x * x;
}
source_file.cpp: In function ‘int main()’:
source_file.cpp:12:43: error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘void’)
cout << "\n" << " the square of num is" <<square(num);
source_file.cpp: In function ‘void square(double)’:
source_file.cpp:19:14: error: return-statement with a value, in function returning 'void' [-fpermissive]
return x * x;
Check the return type of the square function. If it's returning a double value, the return type can't be void.