program for average two number | SoloLearn: Learn to code for FREE!

0

program for average two number

program

c++

8/17/2016 2:44:38 AM

arun ghanghav

3 Answers

New Answer

+1

avoid arithmetic overflow by dividing first then adding. use x/2 + y/2 instead of (x+y)/2

0

#include <iostream> void main() { double x, y; std::cin >> x >> y; std::cout << (x+y)/2; }

0

#include<stdio.h> int main() { double x,y,avj; scanf("%lf%lf",&x,&y); avj=(x+y)/2; printf("%lf",avj); return 0; }