Computer Science, asked by Ekene5491, 1 year ago

Why do do we need variable declaration? give reason?

Answers

Answered by clue
0

C is a compiled language when you program you have to solve the real world problem and you use different types to represent the different data.

If you didnt have a mechanism to do so, how do you tell your computer you need 24 bytes of data allocated for your operation?

Simply, you declare a variable of primitive types (int, float, char, boolean, long) or complex types like (Vector) and you give it a name.

The compiler will know how much memory it has to allocate for the given type.

I hope this has helped :)    

Answered by Anonymous
1

In Java, compiler allocates the memory to the variables that we use in the program. Hence, it is must for the compiler to know the type of value that we would like to store in the memory location allotted to a variable so that necessary arrangement in the memory can be done for its proper storage. This is the reason that why we need to declare a variable before assigning a value to it.

xxxxxxxxxxxxxxxxxxxxxx

Similar questions