Write a program to input two characters and interchange their values.
Answers
#include<stdio.h>
int main() {
double first, second, temp;
printf("Enter first number: ");
scanf("%lf", &first);
printf("Enter second number: ");
scanf("%lf", &second);
// Value of first is assigned to temp
temp = first;
// Value of second is assigned to first
first = second;
// Value of temp (initial value of first) is assigned to second
second = temp;
printf("\nAfter swapping, firstNumber = %.2lf\n", first);
printf("After swapping, secondNumber = %.2lf", second);
return 0;
Answer:
hello,
its a python program
Explanation:
#program to input two characters and interchange their values.
a=int(input("enter the first number"))
b=int(input("enter the second number"))
print("before interchanging")
print("a=",a,"b=",b)
print("after interchanging")
print("a=",b,"b=",a)