Tuesday, 23 June 2015

Pass by value using functions



#include<stdio.h>
main()
{
    int no1,no2;
    printf("Enter two numbers: ");
    scanf("%d %d",&no1,&no2);
    printf("\n Before swap no1 = %d and no2 = %d",no1,no2);
    fnswap(no1,no2);
}
void fnswap(int x,int y)
{
    int temp;
    temp=x;
    x=y;
    y=temp;
    printf("\n After swap no1 = %d and no2 = %d",x,y);
}

OUTPUT
Enter two numbers: 54
69
Before swap no1 = 54 and no2 = 69
After swap no1 = 69 and no2 = 54