Problem Description
Write a C program to convert Float to Integer number
If the value exceed 0.5 then add one to the integer componentCODING ARENA
#include <stdio.h>
int main()
{
float a,b;
int x,y;
scanf("%f%f",&a,&b);
x=(int)(a+0.5);
y=(int)(b+0.5);
printf("Value is:%d",x);
printf("\nValue is:%d",y);
return 0;
}
Test Case 1
Input (stdin)4.6 5.8
Expected OutputValue is:5 Value is:6
Test Case 2
Input (stdin)9.4 9.5
Expected OutputValue is:9 Value is:10
No comments:
Post a Comment