Can a constant and variable be used in the same code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can a constant and variable be used in the same code

Basics

25th Apr 2020, 5:16 AM
Sai syam P S
Sai syam P S - avatar
4 Answers
+ 3
Variable can be constant then why not. in Java we do, public static final String name = "AJ" in JavaScript we write, const name = "AJ" in C we write, const int c = 1;
25th Apr 2020, 5:18 AM
A͢J
A͢J - avatar
+ 1
Sai Syam Check my previous reply.
25th Apr 2020, 5:24 AM
A͢J
A͢J - avatar
0
Give an example
25th Apr 2020, 5:18 AM
Sai syam P S
Sai syam P S - avatar
0
You need to clear that, A constant is also a variable but with fixed value which can never be changed, so technically it doesn't matter if it's a constant or non-constant it's just a variable.
25th Apr 2020, 5:26 AM
Raj Chhatrala
Raj Chhatrala - avatar