go to previous page   go to home page   hear noise   go to next page



Syntax of Variable Declaration

The word syntax means the grammar of a programming language. We can talk about the syntax of just a small part of a program, such as the syntax of variable declaration.

There are several ways to declare variables:

dataType   variableName;
dataType   variableName  =  initialValue ;
dataType   variableNameOne, variableNameTwo ;
dataType   variableNameOne  =  initialValueOne, 
           variableNameTwo  =  initialValueTwo ;

If you have several variables of different types, use several declaration statements. You can even use several declaration statements for several variables of the same type.


Is the following correct?

int answer;
double rate = 0.05;