Write program to read float value from user
To read a floating-point value, specify a float variable and use the appropriate conversion character; %f.
#include <stdio.h> int main()//w ww . ja va 2 s.co m { float fav; printf("What is your favorite number: "); scanf("%f",&fav); printf("%f is my favorite number, too!\n",fav); return(0); }
The scanf() function stops reading text input at the first white space character, space, tab, or Enter key.