To declare (create) a variable, you will specify the type, leave at least one space, then the name for the variable and end the line with a semicolon ( ; ). Java uses the keyword int for integer, double for a floating point number (a double precision number), and boolean for a Boolean value (true or false).
How do you declare a variable example?
Note: All declaration statements must end with a semi-colon(;). For example: int age; float weight; char gender; In these examples, age, weight and gender are variables which are declared as integer data type, floating data type and character data type respectively.
How do you declare a variable in C?
Rules for naming C variable:
- Variable name must begin with letter or underscore.
- Variables are case sensitive.
- They can be constructed with digits, letters.
- No special symbols are allowed other than underscore.
- sum, height, _value are some examples for variable name.