Answer to Question #27919 in C++ for red rose

Question #27919
Write a functions named sqrIt () that computes the square of the value passed to it and displays the result. The function would be capable of squaring numbers with decimal points. Make sure your function is called from main() .
1
Expert's answer
2013-04-09T08:59:20-0400
#include <iostream>

float sqrlt( float x )
{
float result = 0;

// calculate square
result = x*x;

//Show result
std::cout << "square=" << result <<"\n";

return result;
}

int main()
{
float x;
//Show message:
std::cout << "Enter number:\n";
//Read number:
std::cin >>x;

float square;
//call function
square=sqrlt( x );


return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal