Thursday, September 13, 2018

POINTER -4


  • 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
  • CODING ARENA
  • #include <stdio.h>
    #include<math.h>
    int main()
    {
      float a;
      scanf("%f",&a);
      printf("%.0f",round(a));

    return 0;
    }
  • Test Case 1

    Input (stdin)
    3.49
    
    
    Expected Output
    3
  • Test Case 2

    Input (stdin)
    3.50
    
    
    Expected Output
    4

No comments:

Post a Comment