/ Undifined / 5 - WAP Program to Swap Values of Two Variables (Using Third Variable)

5 - WAP Program to Swap Values of Two Variables (Using Third Variable)

Program to Swap Values of Two Variables (Using Third Variable)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*C Program#142 - Program to Exchange or Swap Values of Two Variables.
Version-1 : Using Third Variable
Editor : Code::Blocks 16.01 mingW (Windows) | Source : www.kshitijdivakar.com*/
#include<stdio.h>
int main()
{
    int value1,value2,temp;
    printf("\n\n Enter Value 1 : ");
    scanf("%d",&value1);
    printf("\n\n Enter Value 2 : ");
    scanf("%d",&value2);
    //printing values before swapping
    printf("\n\n Before Swapping : ");
    printf("\n\n\t Value 1 : %d",value1);
    printf("\n\n\t Value 2 : %d",value2);
    //exchange or swap using third variable
    temp=value1;
    value1=value2;
    value2=temp;
    //printing values after swapping
    printf("\n\n After Swapping : ");
    printf("\n\n\t Value 1 : %d",value1);
    printf("\n\n\t Value 2 : %d",value2);
    printf("\n\n");
    return 0;
}

Output

calculate your self

about author

Blogger Sens it website about blogger templates and blogger widgets you can find us on social media
Previous Post :Go to tne previous Post
Next Post:Go to tne Next Post

No comments:

Post a Comment