In: Computer Science
Write a program that calculates the cost per square inch of a circular pizza, given its diameter and price. The formula for area of a circle is
code:
#include<math.h>
#include <stdio.h>
int main()
{
float diameter,area,radius,cost,price;
printf("Enter the diameter of pizza: ");
scanf("%f",&diameter);
printf("Enter the price of pizza: ");
scanf("%f",&price);
radius=diameter/2;
area=(22/7*radius*radius);
cost=price/area;
printf("cost per inch is :%.2f",cost);
return 0;
}
If you code in any langauge (python,c++,java) comment me i will edit my answer.