Skip to content

Instantly share code, notes, and snippets.

@gonzalowtf
Created September 5, 2012 21:46
Show Gist options
  • Save gonzalowtf/3645463 to your computer and use it in GitHub Desktop.
Save gonzalowtf/3645463 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void intercambio1( int, int);
int main (int argc, char *argv[])
{
int var1 = 15, var2 = 27; // Inicio
printf("\nValores antes de llamar la funcion:\t\t %-4d %-4d", var1, var2);
intercambio1(var1, var2);
printf("\nValores despues de llamar la funcion:\t\t %-4d %-4d", var1, var2);
printf("\n");
return 0;
}
void intercambio1( int valor1, int valor2)
{
int aux;
printf("\nValores en la funcion antes del intercambio:");
printf("\t %-4d %-4d", valor1, valor2);
aux = valor1; // (1)
valor1 = valor2; // (2)
valor2 = aux; // (3)
printf("\nValores en la funcion despues del intercambio:");
printf("\t %-4d %-4d", valor1, valor2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment