EXAMPLE 3.1( FIGURE 3.7 Square Root Program)

PROGRAM
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
float first;  //input: one of two data values
float second; //input: second of two data values
float answer; //output: a square root value

//get first number and display its square root.
cout << "Enter the first number: ";
cin >> first;
answer= sqrt(first);
cout << "The square root of the first number is "
<< answer << endl;

// Get second number and display its square root.
cout << "Enter the second number: ";
cin >> second;
answer= sqrt(second);
cout << "The square root of the second number is "
<< answer << endl;

// Display the square root of the sum of first and second.
answer= sqrt(first +second);
cout << "The square root of the sum of both numbers is "
<< answer << endl;
return 0;

}

0 komentar:

Wikipedia

Hasil penelusuran