100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Computer system £10.49   Add to cart

Lecture notes

Computer system

 0 view  0 purchase

Computer system, computer science, computer skills, computer language

Preview 3 out of 30  pages

  • July 24, 2023
  • 30
  • 2017/2018
  • Lecture notes
  • Prof
  • All classes
All documents for this subject (12)
avatar-seller
akhilagouri
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

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller akhilagouri. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for £10.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

67474 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy revision notes and other study material for 14 years now

Start selling
£10.49
  • (0)
  Add to cart