laialii

Troca de valores

Dec 17th, 2015
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void troca (int *a, int *b){
  4.     int auxiliar;
  5.     auxiliar = *a;
  6.     *a = *b;
  7.     *b = auxiliar;
  8. }
  9.  
  10. int main (){
  11.     int a, b;
  12.     printf("Digite o valor de a: ");
  13.     scanf("%d", &a);
  14.     printf("\nDigite o valot de b: ");
  15.     scanf("%d", &b);
  16.    
  17.     troca(&a,&b);
  18.    
  19.     printf("A: %d\nB: %d", a, b);
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment