answersLogoWhite

0


Best Answer

A variable is any named value of a specified type that can hold any value of that type, and that can change that value at any time while the name is in scope. A constant is exactly the same as a variable except that its value must be set at the point of instantiation and the given value cannot be altered while the name remains in scope. In other words, a variable is a value that may vary while a constant is a value that always remains the same.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What do you understand by constant and variable in c plus plus program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What does a constant do in c plus plus?

A constant is a variable that does not change. The correct term is constant variable.


C plus plus program to add a letter in a permanent letters alphabetically?

If by permanent you mean constant, you cannot change something that is constant, therefore you cannot add to it (letters or otherwise). It has to be variable. Constant and variable are mutually exclusive terms.


What is a variable plus a variable?

A variable is a named memory location for which the contents are volatile. The antonym of variable is constant.


What is the constant for 5x plus 9?

9 is the constant. 5 is the coefficient of the variable term. X is the variable term.


What is z if 6z plus 14 equals 8z?

Z is a constant variable in this equation. A constant variable is a variable, the value of which can never change. In this case, z would be equal to 7.


A class in a program whose objects are created and destroyed throughout the program It is desired that the total number of live objects in the program be known how you do this in C plus plus?

Create a static member variable to contain the count. This variable is common to all instances of the class.Initialize that variable to zero at the beginning of the program.In the class constructor, increment the variable.In the class destructor, decrement the variable.


What are the like terms in 8y plus y?

Like terms have the same variable, but can have different constants. 8y : variable is y, constant is 8 y: variable is y, constant is 1 (but this doesn't need to be shown) So yes, theses are like terms.


What is an integer constant in c plus plus?

A constant integer is an integer that is not expected to change value while it is in scope. Declaring any variable constant doesn't guarantee it won't change, but it does make it more difficult for a programmer to change the value by accident. Constant integers must be initialised at the point of instantiation. We can initialise a constant with the value of a literal constant, the value of another constant, or the value of a variable: void f (int v) { const int x {42}; // Integer constant (initialised from literal constant) const int y {x}; // Integer constant (initialised from another constant) const int z {v}; // Integer constant (initialised from a variable) // ... v *= 2; // ok -- v is variable x *= 2; // error: x is constant }


What is an alias name given to a variable in opp with c plus plus?

An alias is a reference, an alternate name for a variable or constant. You can assign the address of any variable or constant to a reference of the same type. A reference is a bit like a constant pointer to the type but, unlike a pointer, a reference has no address of its own thus you cannot store references. More importantly, references can never be NULL. They are simply an alternative name by which you can refer to an existing variable or constant. When you assign a value to an existing reference to a variable, you are assigning the value to the variable itself. When you pass a reference to a function, you are passing the address of the value being referred to, and that address is assigned to the function's reference argument and is local to the function. This is not unlike passing a pointer, but pointers may be NULL, references are guaranteed to be non-NULL (a NULL reference invalidates your program). Note that C++ references are not the same as C reference variables or constants. In C, a reference variable is simply a non-const pointer, while a reference constant is a constant pointer. Hence pointers can be dereferenced (both in C and C++). But in C++, a reference is neither a variable nor a pointer, but is constant (it always refers to the same object and cannot be reassigned once assigned).


What is the constant in 3x plus 7?

The 7 is contant in 3x + 7, and the 3x term is variable depending on the value of x.


In c plus plus are local declarations visible to the function in a program?

If you declare a variable inside of any fuction (except main) it will not be available to other functions.


Has anybody written a Program under classes in c plus plus?

Most likely, even if I don't entirely understand your question.