You are on page 1of 7

Invalid Identifier:

Variables
• Variable is a name that can be -used to store values.
• Variables can take different values but one at a time. These values can be
changed during execution of the program.
• A data type is associated with each variable.
• The data type of the variable decides what values it can take. The rules
for naming variables are same as that for naming identifiers.

Declaration of Variables:
• It is must to declare a variable before it is used in the program.
• Declaration of a variable specifies it& name and datatype.

Initialisation of Variables:
• When a variable is declared it contains undefined value commonly known
as garbage value.
• If we want we can assign some initial value to the variable during the
declaration itself, this is called initialisation of the variable. For example
Compound Statement:

Conversion Specifications:
• scanf( ) and printf( ) make use of conversion specifications to specify the
type and size of data.
• Each conversion specification must begin with a percent sign ( % ).

%c Single character

Reading Input Data:

The scanf( ) function can be written as


scanf("control string" , address I, address2, ....);
• This function should have at least two parameters.
• First parameter is a control string, which contains conversion
specification characters.
• It should be within double quotes.
• The conversion specification characters may be one or more; it depends
on the number of variables we want to input.
• The other parameters are addresses of variables.
• In the scanf( ) function at least one address should be present the address
of a variable is found by preceding the variable name by an ampersand
(&) sign.
• & sign is called the address operator and it gives the starting address of
the variable name in memory
• A string variable is not preceded by & sign to get. the address.

Examples:
Writing Output Data:

You might also like