basic math operations

Basic math operations in programming

Programming world is actually a huge universe with no boundaries. You can create literally “everything” you dreamed in digital world. Games, tools, web sites, web services, mobile apps, more more and more…Only limit is your imagination.

Today, there are lots of programming languages that can be used for varius type of developments. C, Phyton, Php, Java etc..are some examples of mostly used ones in present.

Although each language has its own advantages and disadvantages in particular usage areas, all of them can be used almost every type of development via their core functionalities and pre-built code libraries.

Progress on development means more code written according to project’s scope, but there is a reality almost on every level of development; “using basic math operations“.

Of course not every software development might have math operations, but we can see that 90% of today’s applications have at least a few of it.

For example; if you have to move an element in a web page by using javascript, you will need some basic math operations like sum, subtract, multiply or divide it’s x (horizontal) and y (vertical) positions as pixels.

Thanks to creators of the programming languages, these basic math rules can be used directly like used in everywhere. This means, “+” sign is used to sum, “-” for subtract, “*” is multiplier and “/” is divide.

A simple example for using basic math operations in javascript language.

//Comment texts written after double slash (//).
//Each code must be completed with ";" character.
//Declare a variable named "first_number" by the keyword "var".
var first_number;
//Assign 24 number to variable "first_number".
first_number = 44;
//Declare more numbers.
var second_number = 18;
var third_number = 9;
var fourth_number = 66;
var fifth_element = 0;
//Declare a result variable.
var result;
//Sum the first and second numbers in parentheses, subtract third from fourth in another parentheses, subtract first parentheses result from second parentheses result and assign the result into the variable "result".
result = (first_number + second_number) - (third_number - fourth_number);
//Output of "result" variable is 5.
//Multiply the "result" variable with "fifth_element" and assign the new result into the "result" variable again.
result = result * fifth_element;
//The new value of "result" variable is now 0.

Math operations are frequently used at programming for various tasks like counting, animating, listing etc. Therefore, mastering on basics of math is an important factor of creating algorithms and be a successful programmer.

Leave a Reply