Computer Science, asked by abdulrehmankhan1551, 15 days ago

what are the rules for specifying a variable name in c language


and it should be long answer not short

Answers

Answered by laniban
0

Answer:

A variable in simple terms is a storage place which has some memory allocated to it. Basically, a variable used to store some form of data. Different types of variables require different amounts of memory, and have some specific set of operations which can be applied on them.

A variable name can consist of alphabets (both upper and lower case), numbers and the underscore ‘_’ character. However, the name must not start with a number.

Rules for defining variables

A variable can have alphabets, digits, and underscore.

A variable name can start with the alphabet, and underscore only. It can’t start with a digit.

No whitespace is allowed within the variable name.

A variable name must not be any reserved word or keyword, e.g. int, goto , etc.

Explanation:

Rules for naming a variable

A variable name can only have letters (both uppercase and lowercase letters), digits and underscore.

The first letter of a variable should be either a letter or an underscore.

There is no rule on how long a variable name (identifier) can be. However, you may run into problems in some compilers if the variable name is longer than 31 characters.

C is a strongly typed language. This means that the variable type cannot be changed once it is declared. For example:

int number = 5;      // integer variable

number = 5.5;        // error

double number;       // error

Here, the type of number variable is int. You cannot assign a floating-point (decimal) value 5.5 to this variable. Also, you cannot redefine the data type of the variable to double. By the way, to store the decimal values in C, you need to declare its type to either double or float.

Please mark me as brainliest answer

Similar questions