Created
August 9, 2020 18:33
-
-
Save parzibyte/53ed8f8fc6a43e7f24f02d2e94509011 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
____ _____ _ _ _ | |
| _ \ | __ \ (_) | | | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___ | |
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \ | |
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/ | |
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___| | |
__/ | __/ | | |
|___/ |___/ | |
____________________________________ | |
/ Si necesitas ayuda, contáctame en \ | |
\ https://parzibyte.me / | |
------------------------------------ | |
\ ^__^ | |
\ (oo)\_______ | |
(__)\ )\/\ | |
||----w | | |
|| || | |
Creado por Parzibyte (https://parzibyte.me). Este encabezado debe mantenerse intacto, | |
excepto si este es un proyecto de un estudiante. | |
*/ | |
#include <stdio.h> | |
float calcularVoltaje(float corriente, float resistencia) | |
{ | |
return corriente * resistencia; | |
} | |
float calcularResistencia(float corriente, float voltaje) | |
{ | |
return voltaje / corriente; | |
} | |
float calcularCorriente(float voltaje, float resistencia) | |
{ | |
return voltaje / resistencia; | |
} | |
int main() | |
{ | |
printf("1 - Voltaje\n" | |
"2 - Intensidad de corriente\n" | |
"3 - Resistencia\n" | |
"Seleccione: "); | |
int eleccion; | |
scanf("%d", &eleccion); | |
if (eleccion <= 0 || eleccion > 3) | |
{ | |
printf("Eleccion no valida"); | |
return 0; | |
} | |
float voltaje, resistencia, corriente; | |
if (eleccion == 1) | |
{ | |
printf("\nIngresa la corriente: "); | |
scanf("%f", &corriente); | |
printf("\nIngresa la resistencia: "); | |
scanf("%f", &resistencia); | |
voltaje = calcularVoltaje(corriente, resistencia); | |
printf("\nEl voltaje es: %0.2f", voltaje); | |
} | |
else if (eleccion == 2) | |
{ | |
printf("\nIngresa el voltaje: "); | |
scanf("%f", &voltaje); | |
printf("\nIngresa la resistencia: "); | |
scanf("%f", &resistencia); | |
corriente = calcularCorriente(voltaje, resistencia); | |
printf("\nLa corriente es: %0.2f", corriente); | |
} | |
else | |
{ | |
printf("\nIngresa la corriente: "); | |
scanf("%f", &corriente); | |
printf("\nIngresa el voltaje: "); | |
scanf("%f", &voltaje); | |
resistencia = calcularResistencia(corriente, voltaje); | |
printf("\nLa resistencia es: %0.2f", resistencia); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment