Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 13, 2020 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/513dd4fc7bea7fcdb0b39d906b2ca996 to your computer and use it in GitHub Desktop.
Save parzibyte/513dd4fc7bea7fcdb0b39d906b2ca996 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{
float precioConDescuento, porcentajeDescuento;
printf("Ingresa el porcentaje de descuento: ");
scanf("%f", &porcentajeDescuento);
printf("Ingresa el valor con el porcentaje aplicado: ");
scanf("%f", &precioConDescuento);
// Restamos el porcentaje de descuento a cien
float porcentajeReal = 100 - porcentajeDescuento;
// Y ahora sacamos el valor real. Para ello...
float precioOriginal = (100 * precioConDescuento) / porcentajeReal;
printf("Valor original: %0.2f", precioOriginal);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment