100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Lecture notes

Computer system

Rating
-
Sold
-
Pages
30
Uploaded on
24-07-2023
Written in
2017/2018

Computer system, computer science, computer skills, computer language











Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
July 24, 2023
Number of pages
30
Written in
2017/2018
Type
Lecture notes
Professor(s)
Prof
Contains
All classes

Subjects

Content preview

assumed as auto and stored in the memory. When a variable is declared as register, it is stored
in the CPU registers. The default value of the variable will be garbage value. Scope of the
variable within the block where it is defined and the life of the variables is until the control
remains within the block.

Register variable has faster access than normal variable. Frequently used variables are kept in
register. Only few variables can be placed inside register.

NOTE : We can't get the address of register variable

Sytax : register data_type variable_name;

Ex: register int i;

Ex : void demo(); OUTPUT

void main() 20

{ 20

demo(); 20

demo();

demo();

}

void demo()

{

register int i=20;

printf(“%d\n”,i);

i++;

}

3 : Static Storage class : When a variable is declared as static, it is stored in the memory. The
default value of the variable will be zero. Scope of the variable is within the block where it is
defined and the life of the variable persists between different function calls. To define a variable
as static storage class, the keyword „static‟ is used. A static variable can be initialized only
once, it cannot be reinitialized.

Syntax : static data_type variable_name;


C PROGRAMMING Page 161

, Ex: static int i;

Ex : void demo(); OUTPUT

void main() 20

{ 21

demo(); 22

demo();

demo();

}

void demo()

{

static int i=20;

printf(“%d”,i);

i++;

}



4 : External Storage class : When a variable is declared as extern, it is stored in the memory.
The default value is initialized to zero. The scope of the variable is global and the life of the
variable is until the program execution comes to an end. To define a variable as external storage
class, the keyword „extern‟ is used. An extern variable is also called as a global variable.
Global variables remain available throughout the entire program. One important thing to
remember about global variable is that their values can be changed by any function in the
program.



Systax : extern data_type variable_name;

extern int i;



Ex:


C PROGRAMMING Page 162

, int number;

void main()

{

number=10;

}

fun1()

{

number=20;

}

fun2()

{

number=30;

}

Here the global variable number is available to all three functions.




Ex : void fun1();

void fun2();

int e=20;

void main()

{

fun1();

fun2();

}

void fun1()


C PROGRAMMING Page 163
£10.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
akhilagouri

Get to know the seller

Seller avatar
akhilagouri A Level Notes
View profile
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
2 year
Number of followers
0
Documents
107
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions