Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 28

[Megasoft IT Solution]

Chapter-2: Fundamental of C Language


1.
2.
3.
4.
5.
6.

Constants
Data types
Modifiers
Storage Specifies
Qualifiers
Variable and Type of Variables

An instruction of C language normally consists of a code and the addresses. The


code is to indicate the operation to be performed. The address of the location in the
memory is to locate the data or values or constants on which the operation has to be
performed.
Data or Values or Constants Used in C Language
1. Character Constants
2. String Constants
3. Numeric Constants
1. Character Constants Used in C Language
A symbol or a notation enclosed within single quotes () is referred to as a character
constant in C language. For instance: A, B, C, a, b, c, 0, 1, 2, +, * etc.
The Characters used in C language do not directly understand by the computer. The
CPU only understands the binary notations (i.e. 0 and 1). Hence a character must be
converted into binary notations to the CPU and again binary must be reverted into the
character to the human being. Hence the information interchanging from a character to
binary and vice-versa is needed, which is not available directly. Therefore an intermediate
code that is widely accepted by the world, is used to make possible such type of
information interchange, is referred to ASCII.
ASCII stands for American Standard Code for Information Interchange. ASCII
internally uses 8bits or 1byte to a character. Hence it has total 28=256 characters in C.
It has a unique decimal value for each character range from 0 to 255. For Instance: 65 for A, 66 for B, 67 for C, 97 for a, 98 for b, 99 for c, 42 for *, 43 for +

[Megasoft IT Solution]

2. String Constants Used in C Language


A set of characters enclosed within double quotes () is referred to as a string in C
language. For instance: Welcome
Welcome to C

string of 7 characters
string of 12 characters

Welcome1234567
Welcome To C

strings of 14 characters
strings of 12 characters

Wel3 Come4 to C
30+50=80

string of 15 characters
string of 8 characters

strings of only one character


string of zero length i.e. string of 0 characters

3. Numeric Constants Used in C Language


1. Decimal Number
2. Octal Number
3. Hexadecimal Number
1. Decimal Numeric Constants Used In C Language
A decimal numeric constant can be a number both positive and negative. A decimal
numeric constant must not be started from zero (0). For instance: 20, 30, 40, 234, -234, 40, 30, 20, 358, -543 etc.
2. Octal Numeric Constants Used in C Language
A octal numeric constant C must be started with the zero (0). For instance: 020, 030, 0234, 07654, 0467, 0123, 0345 etc.
3.Hexadecimal Numeric Constants Used in C Language
A hexadecimal number must be started with a zero and a small x or a cap X (0x or 0X).
For instance: 0x203, 0xabc, 0xbca, 0XBCA, 0xFFF4, etc.

[Megasoft IT Solution]

Variables Used In C Language


Variables are the named locations in the main memory, used to store data that can be
manipulated during run-time.
Syntax To Declare A Variable In C Language

Optional

Required

<Qualifier> <StorageSpecifier> <Modifiers>

volatile
const
restrict

auto
static
extern
register

signed
unsigned
short
long
long long

<DataType> <Variables>;

char
int
float
double
void

Points To Be Noted Down: 1. Qualifier, Storage Specifier, and Modifiers are optional and can be
used if needed.
2. signed is the default modifier that means if we not mention any modifier
explicitly, then signed is taken into the consideration implicitly.
3. auto is the default storage Specifier that means if we not mention any storage
Specifier explicitly, then auto is taken into the consideration implicitly.
4. The modifier long long and the qualifier restrict for pointers are supported in
only C99 version of C language.
5. Two variables must be separated by a comma (,).
6. Variables declaration must be terminated by a semicolon (;).

[Megasoft IT Solution]

Variable Naming Conventions Used In C Language


1. A variable name in C language must start with an alphabetic letter (A-Z or a-z),
and can be followed by any sequence of characters except an embedded space ( )
hyphen (-), and dot (.). For instance: 2num
num-2
num 2
num.2
num2
num_2

False
False
False
False
True
True

net-salary
net.salary
net salary
net_salary
Net_Salary
NET_Salary

False
False
False
True
True
True

2. A variable name in C must not be a reserved keyword supplied by C


language. For instance: int
if
for
static
extern
auto

False
False
False
False
False
False

Int
INT
For
FOR
eXtern
EXTERN

True
True
True
True
True
True

3. A variable name in C is case-sensitive that means upper case letters and


lower case letters are different from each other in C language. Example: -

extern
eXtern
Extern
eXTERN
exTern
EXTERN

False
True
True
True
True
True

num2
Num2
nUm2
nuM2
nUM2
NUM2

True
True
True
True
True
True

All variable named are different.

All are different.

[Megasoft IT Solution]

Data Types Supported In C Language


The C compiler provides five fundamental data types, which ensure:

The size to be allocated in the memory


The type of valid data for that memory location

The data types supported by C99 version are given in the table: Data Type
void
char
int
float
double

Size in Byte
0
1
2
4
8

Constants/values/data
No value
A character
A round integer number
A fractional number
A double fractional number

Points to be noted down: 1. The data type void is used to declare a function explicitly returning no value.
It can also be used to declare a generic pointer.
2. The version C99 also supports the type _Bool, _Complex, and _Imaginary.

Examples of Variable Declaration in C Language

To reserve a memory location of one byte named C1


char C1;

Main Memory
Variable Name = C1
Size = 1

Address = FFF4
Type of Data = Only One Character

Memory Mapping: Showing a 1-byte memory location named


C1 in the main memory associated with the relevant information

[Megasoft IT Solution]

To reserve two memory locations each of one byte named C1 and C2 respectively
char C1,C2;

To reserve two memory locations each of 1-byte having values A and B


respectively named C1 and C2 respectively.
char C1=A, C2=B;

To reserve two memory locations each of 2-bytes having decimal values 20 and
30 named num1 and num2 respectively.
int num1 = 20, num2 = 30;

To reserve two memory locations each of 2-bytes having octal values 012 and
022 named num1 and num2 respectively.
int num1 = 012, num2 = 022;

To reserve two memory location each of 2-bytes having Hexadecimal values


0xe5 and 0XE6 name num1 and num2 respectively.
int num1 = 0xe5, num2 = 0XE6;

To reserve three memory locations of the sizes 1-byte, 2-bytes, 4-bytes, and 8bytes having values A, 65, 65.00, and 65.0000 named c1, n1, f1, and d1
respectively.
char c1 = A;
int n1 = 65;
float f1 = 65.00;
double d1 = 65.0000;

[Megasoft IT Solution]

Question-1: Write an application program in C language named P1.C to reserve a two


bytes memory location in the main memory named num. Also display the relevant
informations as given below:

The default value of the location num.


The address of the location num.
The size of the location num.

Solution:-

P1.C
#include<stdio.h>
#include<conio.h>
void main()
{
int num;
clrscr();
printf(Value in num = %d\n\n, num);
printf(Address of num = %p\n\n, &num);
printf(Size of num in bytes = %d, sizeof(num));
while(!kbhit());
}

Question-2: Write an application program in C language named P2.C to reserve two


memory locations each of 2-bytes in the main memory named num1 and num2 having
the values 20 and 30 respectively. Also display the relevant information as given below:

The values stored in the variables.


The addresses of the variables.
The size of the variables.

Solution: -

P2.C
#include<stdio.h>
#include<conio.h>
void main()
{
int num1=20, num2=30;
clrscr();
printf(%d\t%d\n\n, num1, num2);
printf(%p\t%p\n\n, &num1, &num2);
printf(%d\t%d, sizeof(num1), sizeof(num2));
while(!kbhit());
}

[Megasoft IT Solution]

Points To Be Noted Down

Only the name of the variable drops the value of the variable
Ampersand (&) and sizeof() are the operators
& is an address operator, which takes the variable name as an operand and drops
the address of that variable
sizeof() takes a variable name or a data type and drops its size in bytes
All variables are internally addressed in Hexadecimal Notations

Explanations: &variable

Address of the variable

sizeof(type/variable)

size in bytes

Examples: sizeof(void)
sizeof(char)
sizeof(int)

sizeof(float)
sizeof(double)

0
1
2
4
8

char c1, c2, c3;


&c3
&c2
&c1

FFF4
FFF5
FFF6

Int n1, n2, n3;


&n3
&n2
&n1

FFF4
FFF6
FFF8

float f1, f2, f3;


&f3
&f2
&f1

FFF4
FFF8
FFF12

[Megasoft IT Solution]

Cs Memory Map
When a C program is compiled successfully, it creates and uses four logically distinct
regions of memory to hold the programs executable code and the data.
4th Region: STACK
3rd Region: HEAP
2nd Region: GLOBAL
1st Region: Program Code

Points To Be Noted Down:

The First Region is that memory, which holds the programs executable code.
The Second Region or GLOBAL Region or Permanent Region is the memory
where all global variables and static local variables are stored.
The Third Region or HEAP Region is the free memory, which is used to hold
the dynamic variables created during execution or run-time.
The Fourth Region or STACK Region is the memory, which holds the return
addresses of function calls, arguments to functions, and all local variables
except static. It also stores the current state of the CPU.

STACK
Local Variables, Arguments To The Functions and Return
Addressess of the funcions. Also Current State of The CPU
HEAP
Dynamic Variables
GLOBAL
Global Variables and Static Local Variables
Program Code
Programs Executable Code

[Megasoft IT Solution]

10

Types of Variables Used in C Language


C compiler provides facility to reserve locations in the main memory in two ways:

Before Execution that means Compile-Time


During Execution that means Execution-Time or Run-Time

In C language variables can be created even during the execution of the program. The
variables created at execution-time or run-time is referred to as dynamic variables. All
the dynamic variables are allocated in the HEAP Region. Dynamic Variables can be
created with the help of predefined functions named malloc() or alloc().
In C language variables created before the execution of the program (i.e. compile-time)
can be of two types:

Local Variables
Global Variables

Local Variables
A variable declared within a pair of opening and close curly braces are referred to as local
variables. All local variables are created on to the STACK Region and also posses the
properties of a stack.
Example: -

P3.C
#include<stdio.h>
#include<conio.h>
void main()
{
int l1, l2;
{
int l3, l4;
{
int l5, l6;
}
}
{
int l7, l8;
}
}

Note: 10

//Local Variables
//Local Variables
//Local Variables

//Local Variables

[Megasoft IT Solution]

11

Always local variables are declared at the top in a opening and close curly brace.
Properties of Local Variables
The properties posses by a local variable are as follows:

Life-Period or Life-Span
The Default Initialized Value
Accessing

Life-Period or Life-Span of a Local Variable


A local variable is created or allocated with its own opening curly brace and dies or
deallocated with its own close curly brace. Hence local variables are accessible only
within it own opening and close curly brace.
Example: -

P4.C
#include<stdio.h>
#include<conio.h>
void main()
{
int l1, l2;
clrscr();
printf(l1 = %d l2 = %d\n\n,l1, l2);
{
int l3, l4;
printf(l3 = %d l4 = %d\n\n,l3, l4);
printf(l1 = %d l2 = %d\n\n,l1, l2);
}
printf(l1 = %d l2 = %d\n\n,l1, l2);
//
printf(l3 = %d l4 = %d,l3, l4);
while(!kbhit());
}

Explanation: A stack works on the principle LIFO (i.e. Last In First Out). Hence the variables created
last die first and the variables created first die last.
STACK Region

l1

11

l2

Stack1

[Megasoft IT Solution]

12

l4 A Local Variable
l3
Default Initialized Value Of

Stack2

If a local variable is not initialized explicitly at the time of declaration, then it is


initialized implicitly by value garbage.
[Garbage: -The left over dispose of data is referred to as garbage in C]
Example: P5.C
#include<stdio.h>
#include<conio.h>
void main()
{
int l1, l2;
clrscr();
printf(l1 = %d l2 = %d,l1, l2);
while(!kbhit());
}

Accessing A Local Variable In C Language


All local variables are accessible within its opening and close curly brace.
P6.C
#include<stdio.h>
#include<conio.h>
void main()
{
int l1, l2;
clrscr();
printf(l1 = %d l2 = %d\n\n,l1, l2);
{
int l3, l4;
printf(l3 = %d l4 = %d\n\n,l3, l4);
printf(l1 = %d l2 = %d\n\n,l1, l2);
}
printf(l1 = %d l2 = %d\n\n,l1, l2);
printf(l3 = %d l4 = %d,l3, l4); //l3 & l4 not available here
while(!kbhit());
}
12

[Megasoft IT Solution]

13

Global Variables Used In C Language


A variable declared outside opening and close curly brace is referred to as a global
variable or permanent variable. All global variables are created in global region or
Permanent Region and posses the properties of global region.
Examples: -

P7.C

#include<stdio.h>
#include<conio.h>

13

int g1,g2;

//Global Variables

int fucntion1()
{
return(g1);
}

//User defined Function

int g3,g4;

//Global Variables

void main()
{
int l1, l2;
{
Int l3,l4;
}
}

//User defined Function

int g5,g6;

//Global Variables

Int function2()
{
return(g2)
}

//User defined Function

int g7,g8;

//Global Variables

//Local Variables

[Megasoft IT Solution]

14

Properties Of Global Variables


The properties posses by a local variable are as follows:

Life-Period or Life-Span
The Default Initialized Value
Accessing

Life-Period or Life-Span of Global Variables in C Language


Global Variables are created when its declaration encountered first and remain continues
till the end of the program. Hence Global Variables are accessible by codes followed it.
Example: -

P8.C
#include<stdio.h>
#include<conio.h>
int g1,g2;
void main()
{
clrscr();
printf(g1 = %d g2 = %d,g1, g2);
while(!kbhit());
}

//wait for a key

P9.C

14

#include<stdio.h>
#include<conio.h>
int function1();
//Prototype of function1()
int function2();
//Prototype of function2()
int g1,g2;
void main()
//User Defined Function Returning no value
{
clrscr();
printf(g1 = %d g2 = %d\n\n,g1, g2);
printf(g1 = %d g2 = %d\n\n,function1(),fuction2());
while(!kbhit());
}
int fucntion1()
//User Defined Function Returning a value
{
return(g1);
// g1 available here
}
int function2()
//User Defined Function Returning a value
{
return(g2)
// g2 available here
}

[Megasoft IT Solution]

15

Default Initialized Value of Global Variables in C Language


If a global variable not initialized explicitly at the time of declaration, it is initialized
implicitly by value zero(0).
Accessing Global Variables in C Language
Global Variables are accessible by codes followed it.
P10.C
#include<stdio.h>
#include<conio.h>
int g1,g2;
void main()
{
clrscr();
printf(g1 = %d g2 = %d,g1, g2);
printf(g3 = %d g4 = %d,g3,g4); //g3 & g4 not available
while(!kbhit());
}
int g3, g4;
P11.C

#include<stdio.h>
#include<conio.h>
int function1();
int g1,g2;

//Prototype of function1()
//Global Variables

void main()
{
clrscr();
printf(g1 = %d g2 = %d\n\n,g1, g2);
//Available
printf(g3 = %d g4 = %d\n\n,g3,g4);
//Not Accessible
function1();
//Call of function1()
while(!kbhit());
}
int g3, g4;
void fucntion1()
//Definition of function1()
{
printf(g1 = %d g2 = %d,g1,g2);
//Accessible
printf(g3 = %d g4 = %d,g3,g4);
//Accessible
}
15

[Megasoft IT Solution]

16

Storage Specifier Supported or Used in C Language


C compiler provides the following four reserved keywords that ensured the allocation of
the variables:

auto
static
extern
register

auto
The auto storage specifier can only be used with local variables. When no storage
specifier is used with local variables, by default auto is prefixed by the compiler to the
variable name, which allocates the variables onto the stack region. Example: P12.C
#include<stdio.h>
#include<conio.h>
void main()
{
int l1=20, l2=30;
// auto int l1=20, l2=30;
clrscr();
printf(l1 = %d l2 = %d,l1, l2);
while(!kbhit());
//wait for a key
}

Explanation: -

Stack Region

l1

l2

20

30

Memory Mapping
16

[Megasoft IT Solution]

17

static
The static storage specifier can be used with both local and global variables.

static used with global variables


static used with local variables

static used with global variables


when no storage specifier is prefixed with the global variable, by default static is taken
into the consideration by the compiler. static storage specifier allocates the variables onto
the global region, and also posses the properties of global region. Example: -

P13.C
#include<stdio.h>
#include<conio.h>
int g1, g2;
//static int g1=0, g2=0;
void main()
{
clrscr();
printf(g1 = %d g2 = %d,g1,g2);
while(!kbhit());
//wait for a key
}

Explanation: Global Region

g1

g2

0
Memory Mapping

17

[Megasoft IT Solution]

18

static used with local variables


When static storage specifier is prefixed with the local variable, it is allocated onto the
global region and posses the mix up properties of global and local variables.
Static Local Variables are allocated to preserve the previous value of the
variable during different function.
Properties of Static Local Variables

Life-Period
Default Value
Accessing

:::-

Till the end of the program


Zero (0)
Within { and }
P14.C

#include<stdio.h>
#include<conio.h>
void f1();
void main()
{
static int l1, l2;
clrscr();
printf(%d %d,l1,l2);
f1();
while(!kbhit());
}
void f1()
{
Printf(%d %d,l1,l2);
}

//static local variables


//print default values as 0 0

// Not Accessible here

Global Region

Explanation: -

l1

l2

0
Memory Mapping

18

[Megasoft IT Solution]

19

Explanation of Static Local Variable Regarding Preserve Value


P15.C
#include<stdio.h>
#include<conio.h>
void f1();
void main()
{
while(!kbhit())
{
f1();
}
}

//Prototype of Declaration of f1()


//Repeat the work of f1() until a key pressed
//Call To f1()

void f1()
//Definition of f1()
{
int num=20;
//auto lacal variable num
printf(Value of num = %d, num);
printf(\n\n);
num++;
}

P16.C
#include<stdio.h>
#include<conio.h>
void f1();
void main()
{
while(!kbhit())
{
f1();
}
}

//Repeat the work of f1() until a key pressed

void f1()
{
static int num=20; //static lacal variable num
printf(Value of num = %d, num);
printf(\n\n);
num++;
}
19

[Megasoft IT Solution]

20

extern
The extern storage specifier can only be used with global variables. It is used to redeclare the global variables in the block of codes above its declaration (i.e. definition), So
that the global variables can be accessed by the statements above its definition.
Points To Be Noted Down: A global variable is accessible only by the codes followed it.
A global variable can be declared several times but can be defined only once.
Explanation-1: P17.C
#include<stdio.h>
#include<conio.h>
void f1();
void main()
{
clrscr();
printf(%d %d,g1,g2);
f1();
while(!kbhit());

//Prototype or Declaration of f1()

//Not Accessible
//Call To f1()

}
int g1, g2;

//static g1=0,g2=0;

void f1()
{
printf(%d %d,g1,g2);
}

//Definition of f1()
//Accessible

Global Region

g1

g2

0
Memory Mapping

20

[Megasoft IT Solution]

21

Explanation-2: -

P18.C
#include<stdio.h>
#include<conio.h>
void f1();
//Declaration of f1()
void main()
{
extern int num;
//Re-declaration of global g1 and g2
clrscr();
printf(%d %d,g1,g2);
//Accessible
f1();
//Call To f1()
f2();
//Not Accessible
while(!kbhit());
}
int g1, g2;

//Declaration or Definition of global g1 and g2

void f1()
{
printf(%d %d,g1,g2);
}

//Definition of f1()

void f2()
{
Printf(%d %d,g1,g2);
}

//Accessible

//Accessible

Global Region

g1

g2

0
Memory Mapping

21

[Megasoft IT Solution]

22

register
The register storage specifier can only be used with local variables. When register
storage specifier is used with local variables, it stores values directly into the CPU
register rather than main memory.
P19.c
#include<stdio.h>
#include<conio.h>
register int g1,g2;

//Not Allowed

void main()
{
register int l1,l2;
//Allowed
clrscr();
printf(%d %d, l1, l2);
while(!kbhit());
}
Properties posses by register variables: Life-Span or Life-Period
The register variables are created with its own opening curly brace and dies with its own
close curly brace. The register variables are created directly on the CPU-register rather
than main memory (i.e. RAM). Hence it can be accessed within its opening and close
curly braces.
Default Initialized Value
If not initialized at the time of declaration or definition, it is automatically initialized by
value garbage by the compiler.
[Garbage: - The left over dispose of data]
Accessing
The register variables can be accessed within its opening and close curly braces.
Points To Be Noted Down:

Registers are not addressable.


P20.c

22

void main()
{
register int num;
printf(Address of num = %p, &num);
}

//Not Allowed

[Megasoft IT Solution]

23

Modifiers Supported or Used In C Language


The storage capacity of the variables can be modified with the help of modifiers. The
modifiers used or supported in C are given below:

signed
unsigned
short
long
long long

C-99 only

char: - All character variables are of one-byte i.e.; 8-bits. C compiler provides signed
and unsigned modifiers to be used with char data type. By default, if no modifier is
explicitly prefixed with char data type signed is taken into consideration.
Syntax to use signed or unsigned with char: <modifier> <data type> <variable lists>;
Example: <signed or unsigned> <char> <v1, v2, v3, >;
Explanation: char v1=A;

signed char v1=A;

Memory Mapping
v1
char

A
OXFFF4

65

[ASCII value]
01000001

23

1-byte

[Megasoft IT Solution]

24

Left Most Bit or Highest Bit or Sign Bit or Parity Bit


Note: If signed modifier is prefixed with char data type, the left most bit or highest bit is
reserved as a sign bit or parity bit. If the sing bit is 0 then the number is treated as
positive otherwise negative.
0
1

Positive
Negative

Capacity Measurement of char data type variables: Minimum


Maximum

A Negative Value
A Positive Value

Maximum Value: - That can be stored in a one-byte char variable


0

...

Positive Value
0

Maximum Value
Minimum Value: - That can be stored in a one-byte char variable
1

...

Negative Value
1

24

[Megasoft IT Solution]

25
Minimum Value

Binary To Decimal Evaluation: Maximum Value : 0

1
1*20 = 1
1*21 = 2
1*22 = 4
1*23 = 8
1*24 = 16
1*25 = 32
1*26 = 64
0*27 = 0

Now,
(01111111)2

(0 + 64 + 32 + 16 + 8 + 4 +2 + 1)10

127

Hence, 127 is the maximum value that can be hold in a signed char variable, if we try
to store greater than 127 then it will be the case of OVERFLOW.
Explanation: char ch1,ch2,ch3;

signed char ch1,ch2,ch3,ch4,ch5,ch6;

ch1=127;

(01111111)2

(0+64+32+16+8+42+1)10

127

ch2=128;

(10000000)2

(-128)10

-128

ch3=129

(10000001)2 =

((-128) +1)10

-127

ch4=255

(11111111)2

((-128) +127)10

-1

ch5=256

1(00000000) =

(0)10

ch6=257

1(00000001) =
Binary To Decimal Evaluation: -

(1)10

25

[Megasoft IT Solution]

26

Minmum Value : 1

0
0*20 = 0
0*21 = 0
0*22 = 0
0*23 = 0
0*24 = 0
0*25 = 0
0*26 = 0
- (1*27) = -128

Now,
(10000000)2

(0 + 0+ 0 + 0 + 0 + 0 +0 + (-128))10 =

-128

Hence, -128 is the minimum value that can be hold in a signed char variable, if we try
to store greater than 127 then it will be the case of OVERFLOW.
Explanation: char ch1,ch2,ch3;

signed char ch1,ch2,ch3,ch4;

ch1= -128;

2s Complement(1s Complement then plus 1)

-128

(10000000)

01111111+1

10000000

-128

ch2= -129;

10000001

01111111

127

ch3= -130

10000010

01111110

126

ch4= -127

01111111

10000001

-127

unsigned char: - We can prefix the modifier unsigned with char data type variables to
release the sign bit or parity bit, when we have to deal with positive values only. Hence
the range will be 0 to 255.

26

[Megasoft IT Solution]

27

Explanation: unsigned char ch1,ch2,ch3;


ch1=127;
ch2=128;
ch3=129

01111111
10000000
10000001

127
128
129

ch4=255
ch5=256
ch6=257

11111111
100000000
100000001

255
0
1

ch7= 0
ch8= -1
ch9= -2

00000000
11111111
11111110

0
255
254

int: - All int variables have the capacity of 2-bytes i.e.; 16-bits. C compiler provides the
all four modifiers signed, unsigned, short and long to prefix with int type variables.
Note: signed is by default modifier for all type of variables.
Hence unsigned can be used with int to enhance the range of the integer type variables.
Capacity of signed and unsigned char or int variables
signed char

-128

To

127

unsigned char

To

255

signed int

-32768

To

32767

unsigned int

To

65535

Short is same as that of signed int.


Hence range of short int variable is also -32768 to 32767.
long: -

27

[Megasoft IT Solution]

28

long modifier can be used with int, float and double variables. When we use long
modifier then it doubles the existing capacity of the specified type variables.
long int
long float
long double

2*2 = 4 Bytes
2*4 = 8 Bytes
10 Bytes

(32 Bits)
(64 Bits)
(80 Bits)

Capacity of signed and unsigned long int variables


signed long int

-2147483647

To

2147483647

unsigned long int

To

4294967295

Scope Qualifiers Used or Supported in C Language:

const
volatile
restrict

const: - const qualifier can be used in the following format: const <data type> <variable=value>;

Note: A variable declared as const type, once initialized only at the time of declaration and
cannot be modified later on.
Explanation: const int num;
num=20;

Error: - const variable cannot be modified.

const float pi=3.14;


pi=22.7

Error: - const variable cannot be modified.

28

You might also like