Solving 8÷2(2+2) Programmatically


One of the latest trends in the world

Solving 8÷2(2+2)

As you all argue about whether the answer is 16 or 1 on the internet, let’s ask some of the popular programming languages and even GOOGLE calculator the answer.

THE

ANSWER

IS

1

GODAMMIT

ACCEPT THE FACT AND FOLLOW THE EXPLANATION BELOW

#JAVA:

The compiler throws an error for the equation 8÷2(2+2)

prog.java:7: error: ')' expected
        System.out.println(8/2(2+2));
                              ^
prog.java:7: error: not a statement
        System.out.println(8/2(2+2));
                                ^
prog.java:7: error: ';' expected
        System.out.println(8/2(2+2));
                                  ^
3 errors

https://ide.geeksforgeeks.org/7ZMrSyIWJZ – Complete program here

C:

The compiler throws an error again

prog.c: In function 'main':
prog.c:4:11: error: called object is not a function or function pointer
  printf(8/2(2+2));
           ^

https://ide.geeksforgeeks.org/P3pAEva0iC – Complete program here

C++:

COMPILER ERROR !!!!!!

prog.cpp: In function 'int main()':
prog.cpp:5:15: error: expression cannot be used as a function
  cout<<8/2(2+2);
               ^

https://ide.geeksforgeeks.org/fGd9X6HZHL – Complete program here

#PYTHON:

AGAIN !!!!

Traceback (most recent call last):
  File "/home/8c11cbf85a42a9def90843b6f8c83a11.py", line 2, in 
    print(8/2(2+2))
TypeError: 'int' object is not callable

https://ide.geeksforgeeks.org/CrVCZwx5yc – Complete program here

#PYTHON3:

It’s the same…

Traceback (most recent call last):
  File "/home/0be0c7f603d1fd9f6c8acf90fb022c44.py", line 2, in 
    print(8/2(2+2))
TypeError: 'int' object is not callable

https://ide.geeksforgeeks.org/4WOLzNfVtx – Complete program here

#JAVASCRIPT:

Something unexpected happens here, the program stops and RETURN NO OUTPUT!!!

Uncaught TypeError: 2 is not a function
at <anonymous>:2:52
at render (1sgpfVHK8n:206)
at 1sgpfVHK8n:174
at dispatch (jquery.js:4435)
at r.handle (jquery.js:4121)

https://ide.geeksforgeeks.org/tryit.php/1sgpfVHK8n – Complete program here

#GOOGLE CALCULATOR:

So here’s where the INTERNET arguing that the GOOGLE CALCULATOR gives 16

(Oh MAN, how’s that possible!!!)

But the GOOGLE CALCULATOR converts the equation as (8/2)*(2+2) even if you insert 8÷2(2+2)

8÷2(2+2) -> (8/2)*(2+2) is how people getting the answer 16

ACTUAL ANSWER, HOW YOU GET 1:

Solve X/Y(Y+Y) equation you’ll get X/2Y²

Now Substitute X=8 and Y=2

8dividedmeme

Thanks to GEEKS FOR GEEKS – ONLINE IDE