sir what is the need of constant
Question
sir what is the need of constant
Solution
In programming, a constant is a type of variable whose value cannot be changed. It is useful for several reasons:
-
Maintainability: If you use the same value in multiple places in your code, and that value needs to change, you would have to find and update that value everywhere. If you use a constant, you only need to change the value in one place.
-
Readability: Constants can make your code more readable. For example, instead of having a mysterious
3.14159appearing in your code, you could define a constantPIwith that value, making it clear what that number represents. -
Preventing errors: If you try to change the value of a constant, the compiler or interpreter will give you an error. This can help prevent bugs where you accidentally change a value that should stay the same.
-
Optimization: Some compilers can perform optimizations if they know that a value will not change.
In summary, constants are a tool that can help make your code cleaner, more maintainable, and less error-prone.
Similar Questions
ning of the word constant is “to be steady,” and the connotative meaning of constant in the excerpt is “”.
How are the constants declared?
Which of the following statements are true about CONSTANTS?Constants are data items that can change its value.Constants are data items that cannot change its value.It can be an integer or float valueIt can be a string value.Cannot give identifiers for constants
Why is itimportant to introduce the constant of integrationimmediately when you integrate?
Which is the right way to declare constant in C?Question 33Select one:A.int constant var =10;B.int const var = 10;C.const int var = 10;D.B & C Both
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.