previous | start | next

C++ Function Example

At line 17,

                       argument
                          |
                          | 
          y    =    sqrt( i );
                    |       |
                    +-------+
                        |
                   function call
                
                    
    1   #include <iostream>
    2   #include <iomanip>
    3   #include <cmath>
    4   
    5   using namespace std;
    6   
    7   int main()
    8   {
    9     double y;
   10   
   11     cout.setf(ios::fixed);
   12     cout.precision(4);
   13   
   14     cout << setw(10) << "Number"
   15          << setw(13) << "Square Root" << endl;
   16     for(int i = 1; i <= 10; i++) {
   17       y = sqrt((double) i);
   18       cout << setw(10) << i
   19            << setw(13) << y << endl;
   20     }
   21   
   22     cout << endl << endl;
   23     return 0;
   24   }


previous | start | next