Problem Description
Write a program to convert floating point values into its integral equivalent using pointer
Input and Output Format:
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.
Note: In the floating point value mantissa is more equal or more than 0.50 then add one to the equivalent integer value
Refer sample input and output for formatting specification
Note:
If the decimal value is less than 0.50 then print the integer value and if the decimal value is above 0.50 or 0.50 then add one to the integer value.Test Case 1
Input (stdin)3.49
Expected Output3
Test Case 2
Input (stdin)3.50
Expected Output4
Program
#include <stdio.h> #include<math.h> int main() { float a; scanf("%f",&a); printf("%.0f",round(a)); return 0; }
No comments:
Post a Comment
Note: only a member of this blog may post a comment.