Saturday, August 18, 2018

IO 32

  • Problem Description

    Manav had a play with his friend gourav, he gave a number that to read a floating point number and asked him to display the right most digit integral part of the number. Please help gourav to display the right most integral part of the number.

    Explanation :

    If the input is given 124.34, then the output to be displayed is 4 (i.e) Before decimal the integral part is 124 , in that last digit is 4.

    Input and Output Format:

    Refer sample input and output for formatting specification.

    All float values are displayed correct to 2 decimal places.

    All text in bold corresponds to input and the rest corresponds to output.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      float num;
      int x;
      scanf("%f",&num);
      x=(int)num;
      printf("Rightmost integer digit of %.2f=%d",num,x%10);

    return 0;
    }
  • Test Case 1

    Input (stdin)
    233.444
    
    
    Expected Output
    Rightmost integer digit of 233.44=3
  • Test Case 2

    Input (stdin)
    245.124
    
    
    Expected Output
    Rightmost integer digit of 245.12=5

No comments:

Post a Comment