C Variables

Variables also called symbolic variables are the names of storage location of computer memory whose values may vary during execution of a program.

  • These memory locations may contain integer, real or character constant.
  • There are always two values associated with a symbolic variable.
  •   Its data value (read value) stored at some location in memory and is referred as variable’s rvalue.
  • Its location value (address value) the address at which its data value is stored and is referred as variable’s lvalue.

Overview on variables :

Data is stored in a computer's memory. The memory system comprises of uniquely numbered cells called memory addresses. We need to know the address where something is stored in order to retrieve it and work on it. A programming language frees us from keeping track of these memory addresses by substituting names for them. These names are called variables. Variables are descriptive names for the memory addresses.

Before we use a variable in C we must declare it. We must identify what kind of information will be stored in it. This is called defining a variable. Variables must be declared at the start of any block of code, but most are found at the start of each function. A variable must be defined to be one of the legal C data types. When a variable is defined it is not automatically initialized, it is the responsibility of the programmer to initialize this to a start value.

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. Based on the basic types explained in the previous chapter, there will be the following basic variable types −

Type Description
char Typically a single octet(one byte). This is an integer type.
int The most natural size of integer for the machine.
float A single-precision floating point value.
double A double-precision floating point value.
void Represents the absence of type.

Amazing Facts about Programming

Amazing Facts about programming  The first programmer was a lady named Ada Lovelac . She was a writer and gifted mathematician...

Popular Tutorials