Ghislain_Mike

swap two numbers

Feb 15th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main() {
  5.     int a, b, c, d;
  6.  
  7.     printf("Enter a number 'a' = ");
  8.     scanf("%d", &a);
  9.  
  10.     printf("Enter a number 'b' = ");
  11.     scanf("%d", &b);
  12.  
  13.     c = a;
  14.     d = b;
  15.  
  16.     a = d;
  17.     b = c;
  18.  
  19.     printf("The value in 'a' = %d\n", a);
  20.     printf("The value in 'b' = %d\n", b);
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment