If there's no reason you want to use %.2f to scan, just using %f will work
#include <stdio.h>
#include <conio.h>
#define PI 3.14
int main() {
float r,a,c;
printf("enter radius: \n");
scanf("%f",&r);
c = r * PI * 2;
a = r * r * PI;
printf("area:%.2f circumference:%.2f \n",c,a );
return 0;
}
Example:
daniel@daniel-FX503VM:~/Documents/test$ ./zero
enter radius:
1
area:6.28 circumference:3.14
The .2 in the printf is a printing format specifier, and shouldn't have an impact on a scanf
Where you're putting the .2 in the scanf is actually the width field,which specifies the maximum number of characters to be read in the current reading operation (optionally). However, in this context, .2 characters as a width is not a meaningful sentiment, seeing as the width is required to be an integer.
If what you're actually trying to do is only read 2 characters, you could say
scanf("%2f", &r);
But be warned that the '.' would also count as a character.If you specifically just want the output to be two decimal places, then the proposed code above should suffice. If you want to round it internally, I'd suggest you read this post