Saturday, 1 August 2026

Input and Output (I/O)

 I/O stands for Input and Output.

Input is how a program receives data (for example, from the user), and output is how a program shows data (for example, printing to the screen).

Every program usually needs some form of input and output.


Basic Output

Output means displaying data to the screen. All programming languages have a way to do this:


Python
JavaScript
Java
C++
print("Hello World!")

Basic Input

Input means letting the user type something into the program. The program then stores that input in a variable.


Python
JavaScript
Java
C++
name = input("Enter your name: ")
print("Hello, " + name)

Real-Life Example

Here is a simple program that asks the user for their age, and then prints out the year when they will turn 100 years old:


Python
JavaScript
Java
C++
age = int(input("Enter your age: "))
year_to_turn_100 = 2025 + (100 - age)
print("You will turn 100 in the year", year_to_turn_100)

Note: Input methods are different in every language. For example, input() works in Python, while cin is used in C++. In many cases, input is always stored as text first, and may need type casting to be used as numbers.

No comments:

Post a Comment