What is Variable in c - Ishwaranand


What is Variable in c


Q) What is variable?
Q) Define variable.
  • Variable means an entity whose value seat vary (i.e.change) during the specific execution of a program. A perfectly speaking variable is a named memory location." yes, the variable is nothing but another name given to memory location. We can use variable to hold any type of data.
variables science, variables in research, variables in programming, variables in java, variables in math, types of variables, variables in c, variables in python, types of variables in math, variable computer science, variables in research wikipedia, variable, variable and constant, factor coefficient, javascript variable types, declare variable in html, javascript declare keyword, var java, declare variable java, javascript calculation functions, what is a variable in programming, what is a variable in python, how to pronounce variable, what is a variable in math, every variable has the following attributes,
Image Source ~ Crafted With ©Ishwaranand - 2020 ~ Image by ©Ishwaranand

Variable declaration

Q) explain the variable declaration.
Q) write the syntax for declaration of the variable.
  • The declaration means telling the compiler about the name and type of the data hold by the variable, that we want to use in our program. Declaration refers to the process of informing the compiler about the variable used in the program. Before using any variable the variable needs to be declared. 
Following is the general form the declaration of variable:
  • data_type variable_name;
  • data_type - Type of the data hold by the variable.
  • variable_name - Name of the variable. It can be any valid identifier.
For example:

int a;
  • This statement is called a variable declaration. The statement tells the compiler that "a" is the name of the variable and its data type as int(integer) i.e. it can contain any integer value (-32768 to +32767)
float f;
  • Here, f s the variable of type float.

Variable initialization

Q) explain the initialization of a variable.
Q)write the syntax for initialization of a variable.
  • Assigning the to variable at the time of creation or declaration is called as variable initialization or simply initialization.
  • Initialization provides the value to the variable. if the variable is not initialized, then it will contain unpredictable or non-useful(garbage) value.
Following is the form for initialization of variable:
  • data_type variable_name= value;
  • data_type  - Type of the data hold by the variable.
  • variable_name  - Name of the variable. it can be any valid identifier.
  • Value - The initial value that we want in a variable.
For example:

int i = 10;
  • The above statement is called initialization. This statement declares 'i' as the int (integer) variable and will be assigned value '10'
Float pi = 3.1415;
  • The above statement will create a variable called "pi" of type float with "3.1415" as the initial value.

Rule for constructing variable names

Q) write the rules for constructing for constructors.
  • Some variable name is any combination of 1 to 31 alphabets, digits either underscores. Any compilers allow variable names whose distance could be up to 247 characters. still, it would be safer to stick into the rule from 31 characters.
  1. A variable name can contain any alphabet, digit or an underscore.
  2. The first characters in the variable name must be an alphabet or underscore/
  3. A variable name may contain a maximum of 31 characters.
  4. No commas or blanks are allowed within a variable name.
  5. No special symbol other an underscore ( as in gross_sal) can be used in a variable name.

No comments

Comment on Ishwaranand or Happy Day
Not, Add any types of links