ch1-Square
Chapter_1 Hello |
Square.cpp TCP, p. 3-4
#include <iostream>
using std::cout;
using std::endl;
double square(double x); // return square of `x'
void print_square(double x);
int main()
{
print_square(1.234);
return 0;
}
// square a double-precision floating-point number
double square(double x)
{
return x*x;
}
void print_square(double x)
{
cout << "The square of " << x << " is " << square(x) << endl;
}
/*
g++ Square.cpp -o Square
./Square
The square of 1.234 is 1.52276
*/
Chapter_1 Hello | BACK_TO_TOP |
Comments
Post a Comment