|
|
int x=10; float y; x=23; y=32.4;In this sample C++ code segment, the variable x is first declared as an int, and is then assigned the value of 10. Notice that the declaration and assignment occur in the same statement. In the second line, y is declared without an assignment. In the 3rd line, x is reassigned the value of 23. Finally, y is assigned the value of 32.4.
Languages such as Perl do not require variables to be declared before an assignment is made.