Can someone tell me what I am mis-understanding or if there is something I need to do? My code is this:
Code:
#include <stdio.h>
int main (void)
{
int diameter=1;
double radius;
printf("enter diameter to calculate radius:\n");
while(diameter > 0)
{
scanf("%d",&diameter);
radius = diameter / 2;
printf("diam\tradius\n");
printf("\n%4d\t%4.2f\n",diameter, radius);
}
return 0;
}
say I input 10 then 20
my output needs to look like this:
enter diameter to calculate radius:
10
diam radius
10 5.00
20
diam radius
20 10.00
NOT LIKE THIS:
enter diameter to calculate radius:
10
diam radius
10 5.00
20
diam radius
20 10.00
I thought because I did %4.2f that there would be 4 columns total so that the 5.00 would have a blank space before the 5
Thanks for your help