Learn C Language Basics | Learn variables and constants in C

constant variables in c

In C programming language, a constant is an identifier which contains a specific value The value cannot be altered during normal c program execution as the value is constant.
Example
const float PI = 3.1415927; // (Pi is a constant)

for(int i=0;i<10,i++) // i is a variable

Floating-point constants

Floating point constants in C programming tutorial are the type of numeric constants that can either take decimal point or exponent form.
Example:
-2.0
0.0000234
-0.22E-5

Integer constants

Integer constants in C language are the type of numeric constants (constant associated with number) which do not have any fractional part or exponential part.

Three types of integer constants are available in C programming language:

Decimal constant (base 10)
E.g. Decimal numbers: 0 1 2 3 4 5 6 7 8 9
Octal constant (base 8)
E.g. Octal numbers: 0 1 2 3 4 5 6 7
Hexadecimal constant (base 16)
E.g. Hexadecimal numbers: 0 1 2 3 4 5 6 7 8 9 A B C D E F.

Character constants

Character constants in C language are the type of constant which use single quotation around characters. For example: 'l', o', 'v', 'e' etc.

Variables:

An identifier which holds the value that can be altered during normal program execution is called variable. Variables can be visualize as memory location in computer's memory to store data. In other words, Variable names are just the symbolic representation of a memory location.

In C programming following basic variable types are available:

char : This is an integer type. Consume 1 bytes of memory location
int : Contains decimal point free integer value. Consume 4 bytes of memory
float : Single precision floating point value. Consume 4 bytes of memory
double : Double precision floating point value. Consume 8 bytes of memory
void : Represents the absence of type.

The C programming language also gives supports for two important kind of variables which could be used for the dynamic allocation of memory.

Static variable:

static int shared = 3; //shared is of static type variable
Static variable is defined outside all blocks and has static. Always declared outside of main block.

global variable:

global variable in C language is a type of variable which has global scope, In other words, global variable is accessible throughout the program, unless the programmer hides it.

#include <stdio.h>
static int shared = 3; //note declaration of variable just after the library
main()
{
}

===========================================================================

C Programming Modules

===========================================================================

1 . History Of C programming Language

2 . Data Types

3 . Variables & Constants

4 . Operators & Expressions

5 . Decision Making

6 . Loops

7 . Arrays

8 . Functions

9 . Pointers

10 . String Handling

11 . File Handlings

12 . Storage Classes

13 . Preprocessing

===========================================================================