I just started learning C, and I need to take a floating-point input from the user with exactly two numbers after the decimal point and then print it, so I wrote this code:
#include <stdio.h>
int main(void){
float x;
scanf("%.2f", &x);
printf("%f", x);
}
Now say I take 2.14 as input... I don't get 2.14 as output; I get 0.000000. What's wrong with my code??
NOTE: I want the input to be two numbers after the decimal point, and I don't want to do something like:
scanf("%f", x);
printf("%.2f", x);