Variables

variables and datatypes:

  • Data type specifies what kind of data is to be stored in the variable
  • It also specifies how much memory should be allocated for the particular variable.
  • Based on the data types of variables and constants the expression is validated by compiler.
variable Type keyword  bytes Required  Range
character char 1  -128 to 127
unsigned character unsigned char 1  0 to 255
integer int 2  -32768 to 32767
unsigned integer unsigned int 2  0 to 65535
short integer short 2  -32768 to 32767
unsigned short integer unsigned short 2  0 to 65535
long integer long 4  -2,147,483,648 to 2,147,438,647
unsigned long integer unsigned long 4  0 to 4,294,967,295
single-precision floating-point(precision: 6 decimal places) float 4  1.2e-38 to 3.4e38
Double-precision floating-point(precision: 15 decimal places) unsigned long 8  2.2e-308 to 1.8e308

Variables are named memory locations. So you can refer to the data stored at that location using the name rather
than address.
In C, variable names must adhere to the following rules:

  • The name can contain letters, digits, and the underscore character (_).
  • The first character of the name must be a letter. The underscore is also a legal first character, but its use is not recommended. No commas or blanks are allowed within a variable name.
  • Case matters (that is, upper- and lowercase letters). Thus, the names count and Count refer to two different
    variables.
  • C keywords can’t be used as variable names


null

Mr. Sandeep Soni

Founder, Trainer & CEO, Deccansoft Software Services.

Sandeep has 21 yrs of experience working in various Microsoft Technologies/Platforms incl. VB6.0, ASP, VC++, VB.NET, C#. He is involved in managing and architecting projects at Deccansoft. He will be your liaison to Deccansoft, for any kind of communication and project updates. He knows what works and what doesn’t, and what practices are most suitable for design and programming with the ultimate goal of producing a quality system.