4 - Práctica de programación Tema
2 Parte 2
PROGRAMACIÓN ESTRUCTURADA DE MICROCONTROLADORES
Jorge Ruiz Meléndez 00342540 | Valdemar Gómez Vidales 00300602
ING. MECATRÓNICA | INGENIERÍA INFORMÁTICA Y NEGOCIOS DIGITALES | 27/02/2022
Introduction:
In the practice report we will show how we made 5 different codes for 5 different problematics. In
this practice we were using if/else conditions, loops (for, while etc.), and the switch statement. We
will explain the problematic, show the code we developed and finally show the results. This
practice was a little bit more challenging but at the end every exercise was resolved.
Exercise 1. The count of digits in a number:
This exercise output the digits of any number.
The program works by taking the variable “n” and dividing it by ten until its no more an integer
number. We make this program works with a do while condition so the times it need to divide the
number are the number of digits.
Exercise 2. Progress bar:
This exercise asks us to do a progress bar that goes from 0% to 100% and get restarted until we
shut up the program.
We use a for loop to count from 0 to 100 and a Sleep function to see it slower. Then we make an
infinite for loop, so the program run until you press CTRL+C. Finally, we put a print command to
erase the bar (when it gets to 100%) so the code can get restarted in the same line.
Exercise 3. Draw a box with characters:
In this exercise we need to do a program that draw a shape with the width and the height thas a
user input.
This program needs to have 6 char variables that will make de forms of corners and the vertical an
horizontal lines:
At first, we put this code with int variables, and the output was giving us just the numbers, not the
shapes.
We have a while loop that give the user a chance to repeat the process. And the output is the
next:
Exercise 4. Bubble sort:
This exercise ask us to make a program that can sort a number array in ascending order.
In this program we input 20 aleatory numbers in any order and it will accommodate them in order,
from minimum to maximum.
Exercise 5. Restaurant:
This exercise asks us to make a code that takes the order of a restaurant. The user selects from the
4 different options, input the quantity and the program ask if the user want something else.
The program asks the user to input the dish and the quantity. Then the code enters to a while loop
(so you can have another dish) with a switch case statement. Finally, the program gives the total
to the customer.
Conclusion:
Jorge: I think this practice was a little bit more challenging but al the end I was able to do every
exercise (with some help from the teacher and a friend). I think that the exercise that was more
difficult was the draw, because I didn’t know hay characters worked, but a friend helped me to
understand the problem and to make the solution.
Valdemar: Undoubtedly this practice was a little more challenging than the previous one, because
in this one we make use of more functions in our code so that the exercises are solved correctly, as
in the first practice I needed to do some research in terms of Syntaxis of the C language to find the
most optimal way to solve the problem.