Program : Write a program to accept two numbers from user and add them with or without using third variable.
Solution I : Add two numbers using third variable (ans)
a=int(input("Enter first number")) b=int(input("Enter second number ")) sum=a+b print("Sum of",a,"and",b,"is",sum)
Add 2 Numbers in Python
class Hello { public static void main (String args[]) { System.out.println("Hello"); } }
Output :
Enter first number : 87
Enter second number : 87
Sum of 87 and 87 is 174
Solution II : Add two numbers without using third variable.
Addition in Python