HostGator Web Hosting

Incorrect float values are being read using scanf

[ad_1] #include<stdio.h> int main(void) { float val1, val2, diff; int diff_int; printf(“Enter 2 decimal values “); scanf(“%f %f”, &val1, &val2); printf(“You entered: %f and %fn”,val1,val2); diff=val1-val2; diff_int=(int)(diff*100); printf(“Diff: %f or %dn”, diff, diff_int); return 0; } If I enter the values 10 and 9.59, the output for diff_int comes as Read more…