Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 2, 2021 19:40
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/10569fded9af20644effdd8b36bd53aa to your computer and use it in GitHub Desktop.
Save parzibyte/10569fded9af20644effdd8b36bd53aa to your computer and use it in GitHub Desktop.
// https://parzibyte.me/blog
#include <stdio.h>
#define CANTIDAD_NUMEROS 5
double valorAbsoluto(double numero)
{
if (numero < 0)
{
return numero * -1;
}
return numero;
}
int main(int argc, char const *argv[])
{
double numeros[CANTIDAD_NUMEROS] = {
-50,
1.23,
-0.95341,
-10,
500.62};
int i;
for (i = 0; i < CANTIDAD_NUMEROS; i++)
{
double numero = numeros[i];
printf("Valor absoluto de %lf: %lf\n", numero, valorAbsoluto(numero));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment