In a box of total area 10000cm3, Mr. Varun has to pack the balls of given radius “r” and all the balls have the same volume, Help Mr. Varun to find the total number of balls that he can pack in the given box.
Requirements
Capture the radius of the ball “r”
Compute the volume (Hint: Volume=4/3πr3)
Calculate how many number of balls can be placed in the box of 10000cm3 box Display the number of balls packed by Mr. Varun
#include <stdio.h>
int main()
{
double boxVolume = 10000;
double ballRadius;
printf("radius of the ball = ");
scanf("%lf", &ballRadius);
printf("\n");
double ballVolume = 4*3.14*ballRadius*ballRadius*ballRadius;
int balls = (int)(boxVolume/ballVolume);
printf("balls: %d", balls);
printf("\n\n");
return 0;
}
Comments
Leave a comment