Explain why data typing helps the programmer when writing a program

Recommended Answers

All 2 Replies

One of the key benefits of type casting is that you know how the compiler will treat your variables. In the classic example:

var x = 5
var y = "37"
var z = x + y

Some compilers would treat both variables as strings and concatenate them so x+y="537" whilst others would convert the string to an integer and result in x+y=42.

By defining types you know exactly what type of data is stored and how it is treated. It is also more efficient since the memory assigned to the variable will be sized according to the data it will hold, so smaller data types will take up less memory.

How much ever space you need to store your data you require that much memory and datatypes gives you different amount of memory so you can choose based on your requirements.

Take a look at this article - http://en.wikipedia.org/wiki/Data_type

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.