369 TESLAKALVIYOGI
Page 14 of 30

Runtime Addition Program

Add two numbers using user input in 4 languages

</> logic
1

Concept Meaning

A runtime addition program gets two numbers from the user, stores them, adds them, and shows the result.

2

Real-Life Analogy

A teacher asks two marks and adds them immediately on the board.

3

Expected Output

Input 10 and 20 → Output 30
4

Common Mistake

Convert input to number before addition in JS, Python, and PHP.

Same Logic • Different Syntax

Code in 4 Languages

JavaScript
let a=Number(prompt("First:"));
let b=Number(prompt("Second:"));
console.log(a+b);
C++
int a,b;
cin>>a>>b;
cout<<a+b;
Python
a=int(input("First: "))
b=int(input("Second: "))
print(a+b)
PHP
<?php
$a=(int)readline("First: ");
$b=(int)readline("Second: ");
echo $a+$b;
?>

Memory Tip

Input → Store → Add → Output.