JavaScript
let a=Number(prompt("First:"));
let b=Number(prompt("Second:"));
console.log(a+b);Add two numbers using user input in 4 languages
A runtime addition program gets two numbers from the user, stores them, adds them, and shows the result.
A teacher asks two marks and adds them immediately on the board.
Convert input to number before addition in JS, Python, and PHP.
let a=Number(prompt("First:"));
let b=Number(prompt("Second:"));
console.log(a+b);int a,b;
cin>>a>>b;
cout<<a+b;a=int(input("First: "))
b=int(input("Second: "))
print(a+b)<?php
$a=(int)readline("First: ");
$b=(int)readline("Second: ");
echo $a+$b;
?>Input → Store → Add → Output.