Problem Description
Phineas and Ferb who live in the fictional town of danville ,think and do innovatively on weekends. Every day the boys embark on some grand new project, which annoys their controlling sister candace, who tries to bust them. One sunday they were both sitting under a tree in their back yard. They decide to invent a machine which would allow us to enter 2 numbers it would say whether one of the entered number is an appropriate value of the other number entered. They decide to insert a program code in the machine. A number is said to be an approximate value of the other if they differ by utmost 0.5. So write a C program to find whether the given number is approximate number of other.
Input Format:
Input consists of two float type numbers
Output format:
Displays whether the number is approximate or not.CODING ARENA::
#include <stdio.h>
int main()
{
float a,b,c;
scanf("%f",&a);
scanf("%f",&b);
if(b>a)
{
c=b-a;
if(c<=0.5)
printf("Approximate number");
else
printf("Not an Approximate number");
}
else
{
c=a-b;
if(c<=0.5)
printf("Approximate number");
else
printf("Not an Approximate number");
}
return 0;
}
Test Case 1
Input (stdin)14.1 14.6
Expected OutputApproximate number
Test Case 2
Input (stdin)12.1 12.7
Expected OutputNot an Approximate number
i need this code with out if else
ReplyDelete