how to swap two numbers in C?

swap two numbers in C

Add Comment
  • 1 Answer(s)

    Swapping of two numbers in C

    #include <stdio.h>int main()
    {
    int x, y, t;

    printf(“Enter two integers\n”);
    scanf(“%d%d”, &x, &y);

    printf(“Before Swapping\nFirst integer = %d\nSecond integer = %d\n”, x, y);

    t = x;
    x = y;
    y = t;

    printf(“After Swapping\nFirst integer = %d\nSecond integer = %d\n”, x, y);

    return 0;
    }

    Answered on May 8, 2020.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.