The radius of the upper part r1 and lower part r2 is given. If the height of the glass is h and height of the juice is p what is the volume of the juice in the glass? For some input-output is wrong:
#include <stdio.h>
#include <math.h>
int main() {
int r1, r2, h, p;
scanf("%d %d %d %d", &r1, &r2, &h, &p);
//for juice height p we will find out the radius r3
float r3 = ((r1 * p) / h); //calculating r3 by percentage formula
float v = ((M_PI / 3) * 3 * ((r3 * r3) + (r2 * r2) + (r3 + r2)));
printf("Volume : %f\n", v);
return 0;
}
EDIT: After I changed the all int to double still for some input output is wrong for an example for input 5 2 3 2 the answer should be 58.64.