Computer Science, asked by Elesa2984, 9 months ago

Writw a program to input two numbers and interchange their values

Answers

Answered by peterusiju12
0

Answer:

   #include <stdio.h>

   

   int main()

   {

     int x, y, t;

   

     printf("Enter two integers\n");

     scanf("%d%d", &x, &y);

   

     printf("Before Swapping\nFirst integer = %d\nSecond integer = %d\n", x, y);

   

     t = x;

     x = y;

     y = t;

   

     printf("After Swapping\nFirst integer = %d\nSecond integer = %d\n", x, y);

   

     return 0;

   }

Output of program:

Enter two integers

23

45

Before Swapping

First integer = 23

Second integer = 45

After Swapping

First integer = 45

Second integer = 23

Explanation:

To understand the logic choose the variables 'a' and 'b' as '7' and '9' respectively and then do what is being done by the program. You can choose any other combination of numbers as well. Sometimes it's an excellent way to understand a program.

Similar questions