This is my first post and I understand that this website isn't here to do my homework but I'm taking my class online and do not have a teacher in person who I can ask questions so I'm hoping someone on here can help me.
One of the questions for my assignment is to explain each line given to me and explain the difference between each line. I'm going to print out the lines then my explaination of each and their differences and if you find anything wrong or something I left out if you told me that'd be great.
a. int x;
b. int x = 3;
c. x = 3;
I believe line a x is an int variable and the value has not been declared yet
In line b the x is still an int variable but the value has been declared and it is equal to 3
In line c the type of variable isnt declared but it would be called x and equal to 3
The difference between the lines is that a is missing a value, line b is complete, and c is missing the type of variable
Difference Between The Lines
Page 1 of 1
I want to make sure I understand the difference in the lines
1 Replies - 713 Views - Last Post: 23 January 2008 - 08:41 PM
Replies To: Difference Between The Lines
Re: Difference Between The Lines
Posted 23 January 2008 - 08:41 PM
IIRC "declaring" a variable is when you say int x;, definining it is when you give it a value. Other than that, it all looks fine (as long as you know that all of those are valid in certain situations).
Page 1 of 1