Thursday, 28 October 2010

I/O of floats in C

I/O of floats in C

#include <stdio.h>
int main(){
    float a;
    printf("Enter value: ");
    scanf("%f",&a);
    printf("Value=%f",a);    //%f is used for floats instead of %d
    return 0;
}

Output
Enter value: 23.45
Value=23.450000
Conversion format string "%f" is used for floats to take input and to display floating value of a variable.

No comments:

Post a Comment