120k views
0 votes
Write a program to swap two input integer values without using a temporary variable and display the swapped values. The input values have to be obtained using a scanf statement. (In other words, the entire program must require only these two input values to swap them. A third variables must not be declared or used.) [Hint: Try adding the two input integer values and store it as one of the given input values. From there, you can proceed.]

1 Answer

6 votes

Answer:

The program is designed using C programming language

Step-by-step explanation:

#include <stdio.h>

int main () {

printf("Enter the first number here ");

scanf("%f", num1);

printf("Enter the second number here ");

scanf("%f", num2);

num1 = num1 + num2 ;

num1 = num2 - num1 ;

num2 = num2 - num1;

printf("The swapped number num is %f\\", num1);

printf("The second swapped is %f", num2);

return(0);

}

User Mudassir
by
3.0k points