Taking User's Input
We can take input from the user at run time and can store that input in variable. After giving input, press enter.
- Whatever input you give will be stored in variable "name" and we can use this variable when we have to print the name.
- We can also perform some mathematical operation on our input.
- By default, our input has string data type and for doing mathematical operations, we have to convert it into number. We will discus this in string section.
Type Casting
When we want to specify data type for our variable, we use type casting. All the data, which we are taking from the user as input is string type. But to perform mathematical operations, we need numbers. That is why, we need type conversion.
Note: We have converted our string type data into int type data. In the same way, we can convert any type of data into our desired data type to perform specific functions.
Practice Exercises
Complete these exercises to reinforce your learning and earn XP
Sign in to track your progress and earn XP!
Exercise 1 of 2Easy
Which of the following is a best practice in programming?
10 XP~2 min
Exercise 2 of 2Easy
Code that is easy to read and understand is called ___ code.
10 XP~2 min