Question

In: Computer Science

What does it mean to declare a variable? Give an example.

C++ programming homework

What does it mean to declare a variable? Give an example.

What does it mean to assign a value to a variable? Give an example.

What is the different between assigning and initializing? Give examples.

Solutions

Expert Solution

1) Variable declaration
In c++ it is necessary to declare a varibale before using it.
When we declare variable it reserves memory for varible to store value.

Syntax
datatype variablename;

Example
int number;

In this example we created a variable of 'int' datatype
and name of that variable is 'number'.

*****************************************************************

2) Assignment of variable
After declaring variable we can assign the value to that variable.
In the process of variable assignment we store a value in that variable
but in different statement than declaration statement.

Syntax
variablename = value;

Example
number = 100;

In this example we stored 100 into variable 'number'.


*********************************************************

3) Initialization of variable
Initialization of variable means we assign value to the variable
at the time of variable declaration itself.

Syntax
datatype variablename = value;

Example
int number = 100;

In this example we declared a 'int' type variable 'number'
and also assigned 100 to it.


Related Solutions

What does it mean to have a “future taxable amount” and give an example of a...
What does it mean to have a “future taxable amount” and give an example of a temporary difference that would create a deferred tax liability, and what does it mean to have a “future deductible amount” and give an example of a temporary difference that would create a deferred tax asset?
How does one declare a class variable in C#?
How does one declare a class variable in C#?
What does the term "Oppression Olympics" mean? and give example. What does the term "intersectionality" off...
What does the term "Oppression Olympics" mean? and give example. What does the term "intersectionality" off us? What I mean is there are lots and lots of academic terms, right? So what's new about intersectionality? What does it do that other terms have not done? Does it "advance" other theories? Can you name another Intersectional system? Or just start here: Can you name another system where you are both the oppressor and the oppressed within the same system? It's not...
What does it mean when a force is described as “conservative”? Give one example of a...
What does it mean when a force is described as “conservative”? Give one example of a conservative force and one example of a non-conservative force
What does it mean when a method is overloaded? Give an example of overloading the method...
What does it mean when a method is overloaded? Give an example of overloading the method isNotInRange so that can be called like isNotInRange(100, 97, 122);
What does it mean to standardize random variable ?
What does it mean to standardize random variable ?
Questions: 1) // declare integer variable sum equal to zero // declare variable integer i //...
Questions: 1) // declare integer variable sum equal to zero // declare variable integer i // declare while loop condition where i is less then 25 // inside of brackets calculate the sum of i (addition) // increment i // outside the loop print the sum of values ============================================= 2) Create a sentinel value example if I press number 0 it will display the sum of data // create a scanner // prompt the user to to enter the numbers...
What does “national health insurance” mean? Give at least one example of this. Write 250 words...
What does “national health insurance” mean? Give at least one example of this. Write 250 words please
What does Kelly mean when he refers to “creativity”? Give an example of creative thinking from...
What does Kelly mean when he refers to “creativity”? Give an example of creative thinking from your own experience, using Kelly’s cycle to structure your discussion. Contrast Kelly’s definitions of anxiety and aggression with those notions as they were developed by Freud and later by Dollard and Miller. Which theorist’s approach to psychotherapy is most similar to Kelly’s? Explain your answer by comparing both the goals and methods of therapy.
Database Design In the EER modeling process, what does inheritance mean? Give one specific example of...
Database Design In the EER modeling process, what does inheritance mean? Give one specific example of it.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT