Constant and Variables in C Programming

Questions:
What is a constant and a variable?
What is the difference between a constant and a variable?
What are the constants in C?
What are the different types of variable in C?


Answers:

The smallest meaningful units in C programming is called C Token. Keywords, variables, various special characters fall under the c tokens.

Constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are enumeration constants as well. Constants are treated just like regular variables except that their values cannot be modified after their definition.

A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable. The name of a variable can be composed of letters, digits, and the underscore character. It must begin with either a letter or an underscore. Upper and lowercase letters are distinct because C is case-sensitive.

No comments:

Post a Comment

If you need anything to ask, Comment below: