Code Scrappers


Swap two numbers C program


              #include<stdio.h>
              #include<stdlib.h>

              void main()
              {
                    int a, b;

                    printf("Enter value for number 1 : ");

                    scanf("%d", &a);

                    printf("\nenter the value of number 2 : ");

                    scanf("%d", &b);

                    a = a + b;

                    b = a - b;

                    a = a - b;

                    printf("\nAfter swapping number 1 : %d", a);

                    printf("\nAfter swapping number 2 : %d", b);

              }
          



Output

      Enter value for number 1 : 12

      enter the value of number 2 : 34

      After swapping number 1 : 34

      After swapping number 2 : 12