Tuesday, March 31, 2015

Finding the square root

Script

#include <iostream>
using namespace std;
#include <cmath>
int main()
{
        double cover;

        cout << "How many square feet of sheets do you have ? :  ";
        cin >> cover;
        double side;
        side = sqrt(cover);
        cout << "You can cover a square with sides of " << side << " feet with your sheets. \n";
        return 0;
}


Execution

How many square feet of sheets do you have ? :  81
You can cover a square with sides of 9 feet with your sheets.



How many square feet of sheets do you have ? :  144
You can cover a square with sides of 12 feet with your sheets.


How many square feet of sheets do you have ? :  10000
You can cover a square with sides of 100 feet with your sheets.


How many square feet of sheets do you have ? :  34678
You can cover a square with sides of 186.22 feet with your sheets.

No comments:

Post a Comment