Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: karadev on September 04, 2018, 02:11:39 pm

Title: what answer is right in this case :)
Post by: karadev on September 04, 2018, 02:11:39 pm
#include <iostream>
using namespace std;
int main()
{
    // all values are size type int

    int a = 3522;
    int b = 52355;
    int c = 23;
    int d = 2336;
    int e = 501;
    int f = 23432;
    int g = 6743;
    int h = 3;
    long result = 0;
    long result2 = 0;

    result2 = (3522+52353)*23 - (2336*501 + 23432 - 6743)*3;
    // console output result2 = -2275950

    result = ((a+b)*c) - (((d*e)+(f-g))*h);
    // console output result = -2275904

    cout << result2 << "\n";
    cout << result << "\n";
    cout << "press ENTER key for end";

    getchar();

    return 0;
}
Title: Re: what answer is right in this case :)
Post by: sodev on September 04, 2018, 02:38:17 pm
Both are correct. What have i won?
Title: Re: what answer is right in this case :)
Post by: Miguel Gimenez on September 04, 2018, 03:25:45 pm
The value of b is different, anyway this is OT here
Title: Re: what answer is right in this case :)
Post by: stahta01 on September 04, 2018, 05:07:27 pm
Edit: Where are the rules?
Link to rules http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)

**** The link at bottom of post no longer links to the rules!!!!

Tim S.
Title: Re: what answer is right in this case :)
Post by: Jenna on September 05, 2018, 08:59:42 pm
Edit: Where are the rules?
<...>
**** The link at bottom of post no longer links to the rules!!!!

Fixed, thanks for reporting !