Yu know that question mark is use to run the bc command and its does not matter what you write after that.

Creating the Terminal Calculator Function
Now to create the calculator function you need to write this line in the Terminal
? () { echo "$*" | bc -l; }
Now accessing of it is very simple just you need to type ? And then math equation depends on your calculations. You can use the spaces but for that you need to use quotes around the statement otherwise you will see the error like this:

If there is Cygwin is installed in your system then you can use it also on the window. For that purpose there should be bc package installed.

Here you can see the use of bc command.
Making the Function Save across Restarts
If there is Linux or Cygwin in windows then first you have to edit this file and then type this line at bottom.
vi ~/.bash_profile
Now close the terminal and then reopen it then you will see that the command is enabled.

Saving the Function in OS X
If there is OS X in your system then you just need to open the Terminal and then type this,
Touch .profile
Open .profile
Now at this step you should be at default folder that is user folder for the new Terminal window.

To open the file you just need to type open command which will open .profile file in Textedit at there you can past in the line, save and close.

Now close the Terminal, reopen and you can see the function available.