This is my code:
float pi = 3.1415;
float radius, area;
printf("Type the radius of you circle:");
scanf("%f,&radius");
fflush(stdin);
area=radius*radius*pi;
printf("The area of the circle with radius %f is:%f",radius, area);
return 0;
I have a float for PI, for the radius and for the area that will be calculated. The code will ask the user for the radius and then calculate the area.
The problem is: If the user type the radius as a integer, so for example "10" nothing works. I want the user to be able to type both integers and floats as the radius, so both "10" and "10.5" for example. How do I make that work? How can I storage a integer input as a float?