0

program for average two number

program

17th Aug 2016, 2:44 AM
arun ghanghav
3 ответов
+ 1
avoid arithmetic overflow by dividing first then adding. use x/2 + y/2 instead of (x+y)/2
17th Aug 2016, 6:12 AM
Amit Gupta
Amit Gupta - avatar
0
#include <iostream> void main() { double x, y; std::cin >> x >> y; std::cout << (x+y)/2; }
17th Aug 2016, 3:02 AM
Ahkrin
0
#include<stdio.h> int main() { double x,y,avj; scanf("%lf%lf",&x,&y); avj=(x+y)/2; printf("%lf",avj); return 0; }
17th Aug 2016, 12:17 PM
Sourin Banik
Sourin Banik - avatar