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 4 out of 72  pages

  • July 24, 2023
  • 72
  • 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

, The variables a and b are declared as integer type and auto. The keyword auto is
not mandatory. Because the default storage class in C is auto.

Note: A variable declared inside a function without any storage class specification, is by default
an automatic variable. Automatic variables can also be called local variables because they
are local to a function.



Ex : void function1();

void function2(); OUTPUT

void main() 10

{ 0

int x=100; 100

function2();

printf(“%d”,x);

}

void function1()

{

int x=10;

printf(“%d”,x);

}

void function2()

{

int x=0;

function1();

printf(“%d”,x);

}

2: Register Storage class : To define a variable as register storage class, the keyword
„register‟ is used. If CPU cannot store the variables in CPU registers, then the variables are

C PROGRAMMING Page 160

,Storage Classes
In C language, each variable has a storage class which is used to define scope and life time of a
variable.

Storage: Any variable declared in a program can be stored either in memory or registers.
Registers are small amount of storage in CPU. The data stored in registers has fast access
compared to data stored in memory.

Storage class of a variable gives information about the location of the variable
in which it is stored, initial value of the variable, if storage class is not specified; scope of the
variable; life of the variable.



There are four storage classes in C programming.

1 : Automatic Storage class.

2 : Register Storage class.

3 : Static Storage class.

4 : External Storage class.

1: Automatic Storage class : To define a variable as automatic storage class, the keyword „auto‟
is used. By defining a variable as automatic storage class, it is stored in the memory. The default
value of the variable will be garbage value. Scope of the variable is within the block where it is
defined and the life of the variable is until the control remains within the block.

Syntax : auto data_type variable_name;

auto int a,b;

Example:

void main()

{

int detail;

or

auto int detail; //Both are same

}


C PROGRAMMING Page 159

, isalnum(c) Int Determine if argument is alphanumeric. Return nonzero value
if true, 0 otherwise.

isalpha(c) Int Determine if argument is alphabetic. Return nonzero value if
true, 0 otherwise.

isascii(c) Int Determine if argument is an ASCII character,. Return nonzero
value if true, 0 otherwise.

isdigit(c) Int Determine if argument is a decimal digit. Return nonzero
value if true, 0 otherwise.

isgraph(c) Int Determine if argument is a graphic printing ASCII Character.
Return nonzero value if true, 0 otherwise.

islower(c) Int Determine if argument is lowercase. Return nonzero value if
true, 0 otherwise.

isprint(c) Int Determine if argument is a printing ASCII character. Return
nonzero value if true, 0 otherwise.

isspace(c) Int Determine if argument is a whitespace character. Return
nonzero value if true, 0 otherwise.

isupper(c) Int Determine if argument is uppercase. Return nonzero value if
true, 0 otherwise.

toascii(c) Int Convert value of argument to ASCII

tolower(c) Int Convert letter to lowercase

toupper(c) Int Convert letter to uppercase.



6 : TIME LIBRARY FUNCTIONS <TIME.H>

Functions DataType Purpose

difftime(11,12) double Return the time difference 11-12, where 11 and 12
represent elapsed time beyond a designated base time.

time(p) long int Return the number of seconds elapsed beyond a designated
base time.




C PROGRAMMING Page 158

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