Menu Close

Find the sum of numbers with three values after decimal point

Nathan works as an HR in a private company. He had an opportunity to interview students from various disciplines.  He asked the candidates to perform the addition of two floating point numbers given by him an to print the output with three values after decimal point. But the student failed a math test on adding two numbers. So many students could not complete the first round. 

One day Nathan is invited as a chief placement trainer in a reputed engineering college. He willing to know how many students are capable of solving the same problem.

Can you solve the problem and prove him that you are capable of solving it?


Input Format:
The only line of input has two input values of type float separated by a space.

Output Format:
In the only line of output print the sum of two numbers with three values after decimal point

Refer sample input and output:

Input: 19845.67 12985.59

Output: 32831.258
#include <stdio.h>
int main()
{
float var1,var2,res;
//printf("Enter two float numbers: ");
scanf("%f%F",&var1,&var2);
res=var1+var2;
//printf("\nResult with three decimal point: ");
printf("%.3f",res);
	return 0;
}

Input_1:
Enter two float numbers:  19845.67  12985.59

Output:
Result with three decimal point:  32831.258


Input_2:
Enter two float numbers:  23985.12  6545.51

Output:
Result with three decimal point:  30530.629



Input_3:
Enter two float numbers:  2.22  3.22

Output:
Result with three decimal point:  5.440


Input_4:
Enter two float numbers:  6.432  600.1

Output:
Result with three decimal point:  606.532


ILLUSTRATION

Executed using gcc Linux

Morae Q!