Solved programming problem

Swap two Value using Function in C.

Source code

#include <stdio.h>

int swap(n,m);

int main()

{

    int n,m;

    printf("
Please Enter Two Value:");

    scanf("%d %d",&n,&m);

    printf("
The value in Main Function is: %d %d
",n,m);

    swap(n,m);

    return 0;

}

int swap(n,m)

{

    int swap;

    swap=n;

    n=m;

    m=swap;

    printf("
The value in Function is: %d %d
",n,m);

    return 0;

}

Output

Please Enter Two Value:5 10

The value in Main Function is: 5 10

The value in Function is: 10 5

Join the discussion

Add your comment