64.0k views
3 votes
Write a calculate_sq_inches_of_good_pizza function that accepts the diameter of a pizza and returns the area of the pizza minus 1 inch at the edge.

User Verbe
by
6.1k points

1 Answer

5 votes

Answer:

#include <iostream>

using namespace std;

float calculate_sq_inches_of_good_pizza(float diameter) {

float radius= diameter/2;

float pi=3.14;

float area;

area = pi*(radius*radius );

return area;

}

int main() {

float d;

cout<<"enter the diameter of pizza"<<endl;

cin>>d>>endl;

float area_of_pizza = calculate_sq_inches_of_good_pizza();

return 0;

}

Step-by-step explanation:

Above program is written in C++ language which has function namely float calculate_sq_inches_of_good_pizza(float diameter). This will calculate area of pizza from given diameter and return it to main() function.

As we know pizza is circle and area of circle is equal to:

Area = π * radius*radius

π =pi=3.14

and we have calculated radius from given diameter

radius = diameter/2;

If you only want function not whole program than ignore main () function and only consider float calculate_sq_inches_of_good_pizza(float diameter) function which is in ITALIC notation.

User Wwerner
by
5.1k points