Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3.  
  4. void swap(int *p, int *q)
  5. {
  6.     int storage;
  7.     storage = *p;
  8.     *p = *q;
  9.     *q = storage;
  10.     printf("%d , %d", p,q);
  11. }
  12. int main(void)
  13. {
  14.     int a;
  15.     int b;
  16.     printf("Please input a number: ");
  17.     scanf("%d", &a);
  18.     printf("\nEnter another number: ");
  19.     scanf("%d", &b);
  20.     printf("The first variable 'a' will always be shown first. Variable 'b' will follow.\n");
  21.     printf("%d ,", a);
  22.     printf(" %d", b);
  23.     printf("\nNow the two variables' values will be swapped.\n");
  24.     swap(&a,&b);
  25.     printf("\n");
  26.     system("pause");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement