Doing calculationsThis tip submitted by Linuxguru on 2005-01-11 03:52:50. It has been viewed 40963 times.
Rating of 5.5 with 225 votes
Remember when doing calculations in C++, that multiply and divide takes priority above addition and subtraction.
Adding brackets according to these rules, makes it easier to underdstand, and it a neater way to code.
Remember that when you use the cout statement, do not use quotes around an arithmetic expressionas it will simply display the whole line.
Help your fellow programmers! Add a tip!