📜  交换两个数字 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:41.809000             🧑  作者: Mango

代码示例3
#include

void swapping(int, int);  //function declaration
int main()
{
    int a, b;

    printf("Enter values for a and b respectively: \n");
    scanf("%d %d",&a,&b);

    printf("The values of a and b BEFORE swapping are a = %d & b = %d \n", a, b);

    swapping(a, b);      //function call
    return 0;
}

void swapping(int x, int y)   //function definition
{
    int third;
    third = x;
    x    = y;
    y    = third;

    printf("The values of a and b AFTER swapping are a = %d & b = %d \n", x, y);
}