Skip to main content

Posts

Showing posts from July, 2018

Variables and Constants in C

Variables In programming, a variable is a container (storage area) to hold data. To indicate the storage area, each variable should be given a unique name (identifier). Variable names are just the symbolic representation of a memory location. For example: int playerScore = 95; Here, playerScore is a variable of integer type. The variable is assigned value: 95. The value of a variable can be changed, hence the name 'variable'. In C programming, you have to declare a variable before you can use it. Rules for naming a variable in C A variable name can have letters (both uppercase and lowercase letters), digits and underscore only. The first letter of a variable should be either a letter or an underscore. However, it is discouraged to start variable name with an underscore. It is because variable name that starts with an underscore can conflict with system name and may cause error. There is no rule on how long a variable can be. However, only the first 31 characters of a variable a…

Keywords and Identifiers in C

C Keywords Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier. For example: int money; Here, int is a keyword that indicates 'money' is a variable of type integer.  As C is a case sensitive language, all keywords must be written in lowercase. Here is a list of all keywords allowed in ANSI C. Keywords in C Language auto double int struct break else long switch case enum register  typedef char extern return union continue for signed void do if static  while default goto sizeof volatile const float