369 TESLAKALVIYOGI
Page 13 of 30

User Input Basics

Input in JS, C++, Python, PHP

</> logic
1

Concept Meaning

User input means data given by the user while the program is running.

2

Real-Life Analogy

A teacher asks a student for name or marks. A program also asks the user for input.

3

Expected Output

Program receives and stores user data.
4

Common Mistake

Input often comes as text first, so convert to number when needed.

Same Logic • Different Syntax

Code in 4 Languages

JavaScript
let name=prompt("Enter name:");
console.log(name);
C++
string name;
cin>>name;
cout<<name;
Python
name=input("Enter name: ")
print(name)
PHP
<?php
$name=readline("Enter name: ");
echo $name;
?>

Memory Tip

User types → program stores → output shows.