Write a C++ program that has two user-defined functions. The main function will
ID: 3729893 • Letter: W
Question
Write a C++ program that has two user-defined functions.The main function will prompt for all appropriate values as well as output all results.
The program can have one global variable.
The two user-defined functions will both accept one parameter, a radius value. One function will return the area of a circle and the other the parameter of a circle.
All variables are floating-point values. Write a C++ program that has two user-defined functions.
The main function will prompt for all appropriate values as well as output all results.
The program can have one global variable.
The two user-defined functions will both accept one parameter, a radius value. One function will return the area of a circle and the other the parameter of a circle.
All variables are floating-point values. Write a C++ program that has two user-defined functions.
The main function will prompt for all appropriate values as well as output all results.
The program can have one global variable.
The two user-defined functions will both accept one parameter, a radius value. One function will return the area of a circle and the other the parameter of a circle.
All variables are floating-point values.
Explanation / Answer
#include <iostream>
using namespace std;
float result;
float area(float r){
return (3.14 * r *r);
}
float perimeter(float r){
return (2*3.14*r);
}
int main() {
float r;
std::cin >> r;
result=area(r);
std::cout <<"Area of circle is :" << result << std::endl;
result = perimeter(r);
std::cout <<"Perimeter of circle is :" << result << std::endl;
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.