Introduction

What is programming?

Programming is providing the necessary instructions to a machine or device so that it can work automatically.

In every program there are a series of elements that will always be present:

The development of a program consists of the following steps:

  1. Definition and analysis of the problem
  2. Algorithm design using flowcharts.
  3. Program coding: obtaining the source code using the chosen programming language.
  4. Compilation: conversion of source code to machine language.
  5. Bug debugging and program checking.
  6. Operation: documentation and maintenance. In this course, due to the simplicity of the programs created, we will not go into this step, although it is essential that every good program be accompanied by good documentation and a good update plan.

There are a series of principles when designing software that are common:

  • KISS: acronym for Keep It Simple, Stupid! This principle tells us that any system will work better if it is kept simple than if it becomes complex. Simplicity has to be a goal in development and unnecessary complexity must be eliminated.
  • DRY: acronym for Don't Repeat Yourself. This principle talks about the duplication of the code, first of all because of the previous principle, and also because subsequent maintenance becomes more difficult since we do not know where we have to modify things because they are repeated on various occasions throughout the program and the inconsistencies multiply.

For further information about these principles consult here.

Flowcharts

An algorithm is a sequence of steps that must be performed to solve a problem.

A flowchart is a way to represent a process or algorithm in a visual, structured and organized way. It is a very useful tool to organize and structure a programming task before jumping directly into the code.

Example of flowchart:

imagen.png

There are various computer programs for creating flowcharts. Most text processors or slideshow software allow it. However, it is advisable to create flowcharts first with paper and pen, and if appropriate in a collaborative way, and use the software to simply edit them finally to include as program documentation.

Elements of a flowchart

A flowchart is fundamentally made up of the following elements:

imagen.pngProcess: Represents a set of operations that changes value, form, or location of data. Represented as a rectangle.

imagen.png

imagen.png

imagen.png

imagen.png

Simple examples of flowcharts

Example 1: Flowchart of a program that takes two numbers, adds them and shows the result on the screen

SOLUTION:

Flowchart

imagen.png

Example 2: Flowchart of a program that compares two numbers which is larger and displays it on the screen.

SOLUTION:

Flowchart:

image-1654536227461.png