I'm going to use the java-script language as a basis for programming, as it can be used in conjunction with other languages.
Organization of thoughts
Everything in programming starts with how you organize your thoughts to solve a problem.
Think that to solve a problem you will have to break it down into several small tasks or parts to solve it.
Programming logic is a methodology that organizes thoughts to accomplish a certain goal in order to solve a certain problem.
Understand thoughts as sequences of instructions that must be followed to accomplish a certain task to solve a problem
Understand instructions as a set of rules or norms that indicate to a machine the action to perform or perform through an Algorithm.
Algorithm
The algorithm is a set of instructions that will form a program in order to solve a problem.
An algorithm is composed of constants, variables and data.
constants
Constant is a value that changes during program execution.
Variables
It is an element that occupies a position in the machine's memory whose contents can be modified during the execution of a program .
Types of Variables
They can be of 6 types:
Numerical: only made up of numbers, used to make accounts. They can have 3 types:
Integers: var a=30; Float: var b=10.13232; Double (number between -(253 -1) e 253 -1): var c=1.0000000000000004; They can also be used to perform arithmetic operations: var soma= a+b; var soma= a-b*c; var soma= a+b/c;
Characters or strings: only set of letters that do not contain numbers
var name="Marcelo"; var surname="Rabaco"; var full_name=name+" "+surname;
Alphanumeric: can contain either numbers or letters
var age=30; var message=full_name +" have "+age+" yeaers"; Result: Marcelo Rabaco have 30 years;
Logic or Boolean: will only accept the true or false option
var active=true; ou var active=1; var active=false; ou var active=0;
Array: It is a data structure to store a collection of values, being they of any type
var fruits=['orange','apple','lemon']; or var fruits[0]=['orange']; var fruits[1]=['apple']; var fruits[2]=['lemon']; Console.log(fruits[1]) Result: apple
Operators
They are used to compare information. They can be of 3 types::
Arithmetic Operators:
Addition [ + ]
1 + 1 = 2;
Subtraction [ - ]
3 - 2 = 1
Division [ / ]
4 / 2 = 2
Multiplication [ * ]
2 * 2 = 4
Exponentiation [ ** ]
2 ** 3 = (2 * 2 * 2) = 8
Module [ % ]
5 % 3 = 2
Relational Operators:
Equal to [ == or ===]
If ( a == b )
Different [<> or !=]
If ( a != b )
Greater than [ > ]
If ( a > b )
Maior ou igual a [ >= ]
If ( a >= b )
Menor que [ < ]
If ( a < b )
Less than or equal to [ <= ]
If ( a <= b )
Logical Operators
The feedback will always be true or false.
E [ AND ] - the expression is true if both conditions are true
If ( a > b ) AND ( c < b )
Ou [ OR ] - the expression is true if one of the conditions is true
If ( a > b ) OR ( c < b )
Não [ ! ] - Reverse a condition true to false or vice versa in an expression
If ( !(a>b ) )
Let's go to the examples to better understand: