+ 2
Why isn't the printf and return statement outputting the same value for results?
using c/c++, on codeblocks 17.12 https://code.sololearn.com/cMTJ1J31ycqD/?ref=app
7 Antworten
+ 1
Oh I see. In your code it gives good results, but you have to get paranthesis good. Use:
(-b + sqrt(...)) / (...).
If you wont put () around first expression the divide will evaluate first and then add -b to it.
0
Return isn't used for printing out the result on console. It just returns value, so you can assign it to variable or pass as an argument.
0
that's right, but i could output it directly..
int age(int age)
{
return age;
}
int main()
{
cout<<"i am " <<age(1000) <<" years old"<<endl;
return 0;
}
0
you can do
int val = age(1000);
cout<<"age: "<<val;
return only assign a value to variable or printing this value that return
0
its a solution to someone, and i want it to be much more readable..
0
its a solution to someone, and i want it to be much more readable..
0
found the error
instead of %.2f i wrote %2.f