Answer to Question #48750 in C for muammarmubin

Question #48750
1) Write a program to calculate the area of circles

2) Write a program to convert a distance in miles to kilometers. Given 1 Mile = 1.609 km
1
Expert's answer
2014-11-10T10:58:33-0500
/***** The area of circles *******/
#include <cstdlib>
#include <iostream>
using namespace std;
const float pi = 3.14159;

float Area( float r )
{
return pi*r*r; // returns area of the circle
}
int main()
{
float r; // radius
cout << "Enter radius: ";
cin >> r;
printf("The area of circle is: %3.2f\n", Area(r)); //call of the function and print result
system("PAUSE");
return EXIT_SUCCESS;
}



/***** convert a distance in miles to kilometers *******/
#include <cstdlib>
#include <iostream>
using namespace std;
const float Mile = 1.609;

float Dist( float m )
{
return Mile * m; // returns kilometers
}
int main()
{
float m; // radius
cout << "Enter miles: ";
cin >> m;
printf("Distance in kilometers is: %3.3f\n", Dist(m)); //call of the function and print result
system("PAUSE");
return EXIT_SUCCESS;
}

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS