Programming Logic: The End Game
If you are giving your first steps into the technology world, you should learn about programming logic, the foundation of any technology you will ever learn.
TECHCAREER
Laura Oliveira
6/26/20246 min read
When a person starts studying programming, the first subject they should study first is programming logic.
Programming logic is the most important subject that any developer should know, as it is the foundation of any programming language.
And to learn about programming logic, we must go through the following topics:
Programming logic and algorithm;
Phases of an algorithm;
Variables and constants;
Operators;
Decision structures;
Repetition structures.
1. Programming logic and algorithm
Programming logic is the ability to create an algorithm for a computational problem without using a programming language, that is, creating a solution to a problem using computer logic.
Algorithm is the sequence of steps used to solve a given problem.
In other words, through programming logic you are able to list a sequence of steps to solve a given problem.
How to create an algorithm?
Identify the problem;
Visualize a possible solution;
Break this solution into small steps;
Identify the structures of the programming language in question that can be used to assemble the solution, according to its syntax;
Test the solution;
If the solution works: move on to the next problem;
If not: try to improve the solution or create a new solution.
2. Phases of an algorithm
The phases of an algorithm are the main elements that every solution must have, to achieve the expected objective.
The phases of an algorithm are:
Input: information that starts the algorithm;
Processing: steps necessary to solve the problem and achieve the desired objective (problem resolution);
Output: results of the processing phase.
3. Variables and constants
A variable is a memory space inside the computer used to store information.
They're like bricks with different shapes and weights, where each brick will store a different information.
The brick's format is like the types of variables (integer, string, float, etc.). It's the place where we will define which types of bricks we're going to use in our software.
While the brick's weight will be the amount of information that each variable can store, for example, within an int variable we can store integers that fit within 4 bytes of memory,
We define a name and/or type for this variable, so that our program can save and read the data correctly after creating this variable.
A variable can have a predefined type, depending on the programming language used.
For example: a car space can be considered a variable. It is a space designed to "store" a car for a certain period of time, and which may or may not have a pre-defined type and space (space for car or motorcycle).
Why do we need to define a type for a variable?
For the program can reserve the necessary amount of space in the computer's memory to save the data used in our software.
Definition of constant
Constant is a space reserved in memory to store a fixed value, that is, it cannot be modified in the future.
Variable types
Variables and constants can basically be of four types:
Numeric (integer or real);
Alphanumeric;
Logical;
Character.
Numeric type
The numeric type is specific for storing numbers, which can later be used for calculations. They can also be classified as integers or reals.
Integers: Integers are those that do not have decimal or fractional components, and can be positive or negative.
Real: real numbers are those that can have decimal or fractional components, and can also be positive or negative.
Alphanumeric type
The alphanumeric type is made up of a sequence of letters, digits and/or special symbols.
Logical type
The logical type is used to represent two only possible logical values (true or false). Other ways to represent this data are: yes or no; 1 or 0; true or false.
4. Operators
An operator is a symbol that represents the execution of calculations and data manipulation between variables and constants. Because the person who actually performs the processing is the computer's processor.
Operators are classified into three types:
Arithmetic operators (acts with one or two variables);
Relational operators (acts with two variables);
Logical operators (acts with two or more variables).
Arithmetic operators
They are symbols used to perform arithmetic operations and can act on one or two variables.
When arithmetic operators act on a variable, it is only possible to change their sign from positive to negative, and vice versa.
Relational operators
Relational operators are symbols used in logical expressions to test the relationship between two values of the same type, returning true or false.
Logical operators
Logical operators are used when there is a need to test two or more conditions simultaneously. Its symbolic representation varies depending on the programming language.
5. Decision structures
Decision structures aim to test whether the past condition is true. How repetition structures work:
If the condition is true, a block of code is executed
If the condition is false, another block of code is executed
These decisions are made throughout the execution of the program
6. Repetition structures
Repetition structure is a structure that allows you to execute the same command or set of commands more than once, according to a condition or a counter.
There are three basic repetition structures for virtually all programming languages:
while;
do while;
for.
While command
The while statement allows a certain part of the program to be executed while a certain condition is true. The form of the while command is as follows:
This command works as follows:
Test the condition;
If the condition is false, exit the while statement code block and move to the next code block;
If the condition is true, execute all commands that are within the while command;
After executing the last command of the while block, return to step 1, until the condition is false.
The while command should be used whenever:
We don't know exactly how many times the loop should be repeated;
The test must be done before starting to execute a block of commands.
There are cases where the loop should not be repeated once.
Do while command
The do while command is very similar to the while command, its only difference is: the block of commands is executed before the condition is checked. The form of the while command is as follows:
How it works is as follows:
Executes the commands within the while block;
Test the condition;
If the condition is false, execute the code that comes immediately after the while command;
If the condition is true, go back to step 1, until the condition is false.
The do while command should be used whenever:
We don't know exactly how many times the loop should be repeated;
The test must be done after executing a block of commands;
The command block must be executed at least once before the condition is tested.
The for command
The for command allows a certain piece of program to be executed a certain number of times. The form of the for command is as follows:
How it works is as follows:
Executes startup commands;
Test the condition;
If the condition is false, exit the for command code block and execute the code that follows;
If the condition is true, execute the commands in the for command code block;
Executes increment/decrement commands;
Return to step 2 until the condition is false.
The for command should be used whenever:
We know exactly how many times the loop must be repeated;
The test must be done before executing a block of commands.
There are cases where the command should not be repeated once.
And these are the first steps for you who want to enter this area that has infinite possibilities.
The path has just begun, so keep studying and when "luck" knocks on your door, it will find you working!












Laura Oliveira
Mobile Developer and Content Creator
Fascinated by technology since she was a teenager, she loves solving problems and learning new things.
I currently work bringing ideas to life for Android apps.
I have +2 million people impacted through the production of digital content.


2M+
3
Years Creating Content
Content Reach