In section 4.4.2.1, "while statements", Bjarne shows an example of a square()
function. But I am getting the following error, why?
square identifier not found
I am trying to figure out how to use this program so then I can code the TRY THIS exercise. I try to define or declare the function, and maybe that is the problem, or I really don't know. I do know the C++ doesn't have a square()
function. What am I doing wrong?
Here is the code that I created:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
double square( double value)
{
return (value * value);
}
int main()
{
int i = 0;
while (i < 100)
{
cout << "please enter a number: \n";
cin >> i;
cout <<i<< '\t' << square(i)<< '\n';
++i;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire