Swap Two Variable using Call by Reference

-- 1 comment
Hello Here is a C program to Swap Two integer variable using call by reference.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
void swap (int *o, int *p)
{
    int tmp;
    tmp = *o;
    *o = *p;
    *p = tmp;
}
main ()
{
    int a,b;
    printf("Enter the value of A:- ");
    scanf("%d",&a);
    printf("Enter the value of B:- ");
    scanf("%d",&b);
    printf("\nBefore Swap:-\nA = %d\nB = %d",a,b);
    printf("\nAfter Swap:-");
    swap(&a, &b);
    printf("\nA = %d\nB = %d",a,b);
}


Hello This is Sagar Devkota. Studying Bachelor of Software Engineering at Pokhara University. I know something about Linux, Android, Java, Nodejs, Unity3D and 3 dots :)

1 comment: Leave Your Comments

  1. We accept all main banking strategies for deposits and withdrawals, together with MasterCard and Visa, pay by cellular , Trustly, Skrill, Instant financial institution transfer and Pay 더킹카지노 Safe. Play a number of the} finest on-line slots around when you sign up with no deposit at Free Daily Spins! We have slots to scratch your spinning itch from a number of the} finest builders within the business together with Big Time Gaming, NYX, Barcrest, Pragmatic Play, WMS, Bally and Thunderkick. Choose from over 600 video games including a number of the} finest on-line slots out there.

    ReplyDelete