lesson 12 sqrt cpp
[[lesson_12_sqrt_cpp]] last edit on Aug 18, 2005 7:00 AM by rescued_by_c

[user02@FC4 Lesson12]$ cat -n sqrt.cpp
   1  #include <iostream>
   2  #include <cmath>        // Contains sqrt prototype
   3  using namespace std;

   4
   5  int main()
   6  {
   7     cout << "The square root of 100.0 is " << sqrt(100.0) << endl;
   8     cout << "The square root of 10.0 is " << sqrt(10.0) << endl;
   9     cout << "The square root of 5. 0 is " << sqrt(5.0) << endl;
  10
  11     return 0;
  12  }
[user02@FC4 Lesson12]$ g++ -o sqrt sqrt.cpp
[user02@FC4 Lesson12]$ ./sqrt
The square root of 100.0 is 10
The square root of 10.0 is 3.16228
The square root of 5. 0 is 2.23607
[user02@FC4 Lesson12]$