Inversor de números de tres cifras [ESP-ENG] | C++

in Develop Spanish3 years ago (edited)

Portada.jpg

Saludos compañeros de Hive, hoy les traigo un programa un poco más corto, se trata de un inversor de números de tres cifras. Lo hice en 2020 cuando estaba viendo "Programación Orientada a Objetos" como materia en la universidad, fue la primera vez que usé un bucle do while, en esta ocasión lo mejoré un poco y quise compartirlo por acá.

Greetings fellow Hive members, today I bring you a program a little shorter, it is a three digit number inverter. I made it in 2020 when I was watching "Object Oriented Programming" as a subject in college, it was the first time I used a do while loop, this time I improved it a little bit and I wanted to share it here.


image.png

image.png

Programación c++.png


Para empezar como siempre incluí las librerías aunque analizandolo una de ellas no es necesaria en este caso, se puede omitir stdio.h, luego el using namespace para facilitar el uso de la entrada y salida de datos. En el main declaré cuatro variables, inv, dig1,dig2,dig3, esto para recibir el número del usuario (inv) y luego validarlo, para evitar que ingrese numeros qeu no sean de tres cifras, las otras tres son para almacenar cada dígito, por medio de los operadores de división y módulo uno recibi el residuo de la división entre 10 y el otro retira un digito, pues al dividir de forma entera, entre 10, eso es lo que sucede. Ejemplo: 100/10 = 10 , 123%10=3. Esos dos operadores han sido bastante recurrentes en los ejercicios que he compartido por acá.

Los condicionales if else están colocados de manera que también se pueda culminar el programa si se ingresa 0 (por la condición del do while), de no hacerlo, cada vez que se muestra un número invertido, se puede reiniciar el programa para ingresar otro número.

To begin as always I included the libraries although analyzing it one of them is not necessary in this case, you can omit stdio.h, then the using namespace to facilitate the use of the input and output of data. In the main I declared four variables, inv, dig1,dig2,dig3, this to receive the number of the user (inv) and then validate it, to avoid that it enters numbers that are not of three digits, the other three are to store each digit, by means of the operators of division and module one receives the residue of the division between 10 and the other one removes a digit, because when dividing in an integer form, between 10, that is what happens. Example: 100/10 = 10 , 123%10=3. These two operators have been quite recurrent in the exercises that I have shared here.

The conditional if else are placed so that also the program can be finished if 0 is entered (by the condition of the do while), otherwise, every time that an inverted number is shown, the program can be restarted to enter another number.

image.png

Programación c++.png

image.png

¡Eso ha sido todo! Este ejercicio era más corto que los anteriores pero me trajo bastantes recuerdos de aquellos primeros pasos. Aunque la verdad aún sigo siendo un bebé en esto, seguiré estudiando para crecer y compartir más de este apasionante mundo por acá.

Si te interesa otro tutorial de programación acá te dejo los links a los que he realizado hasta ahora:

That was it! This exercise was shorter than the previous ones but it brought back a lot of memories of those first steps. Although the truth is that I'm still a baby in this, I will continue studying to grow and share more of this exciting world around here.

If you are interested in another programming tutorial here are the links to the ones I have done until now:


Calculador de datos para un triángulo rectángulo en C++

Concecionario de autos, ejercicio en JAVA

Calculador de edad básico C++

¿Cuántos números de 3 cifras existen cuya suma sea 10? - ¡Respondiendo a otro usuario! C++

Programación c++.png

Puedes seguirme por acá si lo deseas:
You can follow me here if you want:

Diseño sin título.gif

Cuenta secundaria
(Dibujos, edición y juegos) | Secondary account (Drawings, editing and games)

Sort:  

Gracias @gabrielr29 por participar en la actividad Curaciones Matutinas, ¡Feliz día!

Your content has been voted as a part of Encouragement program. Keep up the good work!

Use Ecency daily to boost your growth on platform!

Support Ecency
Vote for Proposal
Delegate HP and earn more

Congratulations @gabrielr29! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You received more than 10000 upvotes.
Your next target is to reach 15000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Feedback from the June 1st Hive Power Up Day
 3 years ago  

Que bueno que compartes tu codigo y no te preocupes son practicas sencillas pero todos empezamos ahi, es bueno tenerlo, aprenderlo y seguir creciendo

¡Así es! Gracias por pasarse por acá :D