answersLogoWhite

0

When you want to use a variable, first you declare it: int iNumber; which is basically just stating that you will be using an int type variable named iNumber. Then you should initialise it: iNumber = 0; which is giving the variable an initial value so that it contains a known value rather than just a random value that happens to be in memory. Of course you can use the shorthand: int iNumber = 0; to both declare and initialise using one statement.

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is the difference between declaration and initialization?

Perhaps an example will help. extern int value; /* declaration */ int value; /* definition */ int value= 20; /* definition with initialization */


What is Variable declaration and variable initialization?

...are important things in programming. Example: extern int variable; /* declaration */ int variable= 8; /* definition with initialization */


When variable in c gets memory After declaration or initialization?

Definition. Example: extern int x1; /* declaration */ int x2; /* definition */ int x3= 2; /* definition with initialization */


What is the difference between declaration and a definition in C with small example?

declaration examples:int main (void);extern int somevariable;definition examples:int main (void) { puts ("Hello world"); return 0; }int somevariable;


How do you write a for loop program in java?

The for loop is especially useful for flow control when you already know how many times you need to execute the statements in the loop's block. The for loop declaration has three main parts, besides the body of the loop: • Declaration and initialization of variables • The boolean expression (conditional test) • The iteration expression The three for declaration parts are separated by semicolons. The following two examples demonstrate the for loop. The first example shows the parts of a for loop in a pseudocode form, and the second shows a typical example of a for loop. for (/*Initialization*/ ; /*Condition*/ ; /* Iteration */) { /* loop body */ } Ex: for (int i = 0; i<10; i++) { System.out.println("i is " + i); }


What type of loop is the for loop?

The for loop is especially useful for flow control when you already know how many times you need to execute the statements in the loop's block. The for loop declaration has three main parts, besides the body of the loop: • Declaration and initialization of variables • The boolean expression (conditional test) • The iteration expression The three for declaration parts are separated by semicolons. The following two examples demonstrate the for loop. The first example shows the parts of a for loop in a pseudocode form, and the second shows a typical example of a for loop. for (/*Initialization*/ ; /*Condition*/ ; /* Iteration */) { /* loop body */ } Ex: for (int i = 0; i<10; i++) { System.out.println("i is " + i); }


What is the difference between has and have and give an example?

the difference between has and have is that you use has in sentences with : ( she , he and it ) for example : she has a book . but you use have in sentences with : ( I , you , we and they ) for example : you have a book , I have a book .


What is pointer initialization?

Assigning an initial value to a pointer variable. Example: int *p= NULL;


Difference between eg and ie?

example given......in example


Difference between object declaration and object creation?

Declaration of the object involves only creating the reference variable to the object. Example: class SampleClass{ } Object Declaration: SampleClass obj1; Object Creation: Creating an object involves use of new keyword and actually allocating memory for that object. SampleClass obj2 = new SampleClass ();


What is the difference between local market and national market explain with example?

what is the difference between local market and national market


What difference in meaning is there between ' for example' and ' for instance'?

There is very little difference unless you take away the 'for' :)