Up till now, we have displayed a pre-decided text— ‘Hello, World!’ on the screen. No matter how many times we run the program, the same text will be displayed.

In programming, “hard coding” refers to the practice of embedding specific values or data directly into the code instead of allowing them to be determined at runtime by getting them as user input or extracting them from external files.

Variable in memory locations

What if we wanted to print a different text each time? What if we wanted the user to decide what needs to be displayed? Suppose we need to write a program that displays the user’s age. To make this possible, the programming language needs to provide us with a feature using which we can take the input from the user, save it to a memory location, and retrieve it from the memory location whenever the program requires it. Have a look at the following slides:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy