Swapping two numbers || method 1 || Basic programs || C programming
In this, we are going to write a program to swap the values of two variables using an extra variable i.e. Method-1 in C Programming Language.

#include <stdio.h>

void main()
{
    //Declaring variables
    int a, b, c;
    printf("Enter value of a and b: ");

    //Taking Inputs
    scanf("%d %d", &a, &b);
    printf("The values Before Swaping:\na = %d\nb = %d\n", a, b);

    //Swapping values
    c = a;
    a = b;
    b = c;

    ////Printing Swapped values
    printf("The values After Swaping:\na = %d\nb = %d\n", a, b);
}

//......Coded by MANSI DESHMUKH
#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post