Hey,
Well I am fairly new to C++ and am supposed to create a program that compares various pizza's between size and price so the unit would be dollar/area^2

The input from the user should first be how many items you have to compare..
The next input from the user should be the price of the pizza and the diameter of the pizza in inches.
So I have got that down.... But I don't know how I would save each input (inches and price) so that they are saved in seperate variables and could calculate the final value of the pizza (dollar/area^2) and how to compare them.... This program so far compiles and runs...
This is what I have so far

``````#include <stdio.h>
int main ()
{
int items;
float inches;
int i = 0;
float price;
float area;
float final;

printf("The number of pizza options you have?\n");
scanf("%d", &items);

while(i++, i<=items){
printf("How big is the pizza diameter in inches?\n");
scanf("%f", &inches);
printf("How much does the pizza cost?\n");
scanf("%f", &price);
}
area=(PI*inches)
final=(area/price)

}``````

Could someone help me out and point me at the right direction ?
Thanks!

First, the code you posted uses pure C syntax so it may be better posted on the C board. However, the logic will be the same whether it's C or C++, only the syntax will differ.

Since the area of a circle is the product of pi times the square of the radius you can neglect the pi part and just use the radius squared part in the calculation of the relative cost. The radius is the diameter divided by 2 and to square it you can either use the pow() function or mulitply the radius by itself.

If all you want to know is the cheapest or the most expensive, then you can just keep track of the appropriate values on and ongoing basis during the input loop.

input cost
input diameter