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

2) Write a program to convert a distance in miles to kilometers. Given 1 Mile = 1.609 km

Expert's answer

/***** 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;

}

#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;

}

## Comments

## Leave a comment