Exercise 30
Write a program which reads float value developed as decimal extension and
- If it's integer, it says that it's integer
- on the other hand it rounds it to integer and writes the result.
Remember about data control
Here's the new one without this message about integer type.
#include <stdio.h>
#include <math.h>
int main(){
double x; //the argument of f(x)
printf("Program demands x");
printf("\nand writes the rounded value\n");
printf("Author: xXx\n\n");
//loading data
printf("Write x in float type in decimal extension "); // after many tries, program is not rounding the value
if (scanf("%lf",&x)!=1 || getchar()!='\n'){
printf("Wrong data.\n");
printf("\nEnd of program.\n");
return 0;
}
double round( double x );
printf( "Rounded value is = %lf\n", x);
printf("\nEnd of program.\n");
return 0;
}