#include<iostream>
usingnamespace std;
int main() {
int a,b,c;
cout<<"Write two numbers that you want to get avarage"<<endl;
cin>>a;
cin>>b;
c=a + b/2;
cout<<"Your number is: "<<c<<endl;
char z;
cin>> z;
return 0;
}
I get random number... i think c=a + b/2; doesn't work good.
Or just add brackets around a+b... Mathematics rules state that you divide before adding.. Brackets however are to be solved before going on with the rest..
In other words, by adding brackets around the a+b, it'll first add those, and then divide it by 2 :)