APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY Previous Years Question Paper & Answer

Course : B.Tech

Semester : S1 and S2

Year : 2017

Term : DECEMBER

Branch : BIOTECHNOLOGY

Scheme : 2015 Full Time

Course Code : CS 100

Page:47





PDF Text (Beta):

Yes, there could be if these variables are defined in different blocks. So, there
will be no error here and the program will compile and execute successfully.
The printf in the inner most block will print 3 and the variable 1. defined
in the inner most block gets destroyed as soon as control exits from the block.
Now control comes to the second outer block and prints 2 then comes to the
outer block and prints 1. Here, note that automatic variables must always be
initialized properly, otherwise you are likely to get unexpected results because
automatic variables are not given any initial value by the compiler.

2. Register Storage Class

The register specifier declares a variable of register storage class.
Variables belonging to register storage class are local to the block which
they are defined in, and get destroyed on exit from the block. A register
declaration is equivalent to an auto declaration, but hints that the declared
variable will be accessed frequently; therefore they are placed in CPU
registers, not in memory. Only a few variables are actually placed into
registers, and only certain types are eligible; the restrictions are
implementation-dependent. However, if a variable is declared register, the
unary & (address of) operator may not be applied to it, explicitly or
implicitly. Register variables are also given no initial value by the compiler.

The following piece of code is trying to get the address of variable 1൩0
pointer variable ‏م‎ but it won't succeed because [ is declared register;
therefore following piece of code won't compile and exit with error "error:
address of register variable requested".

#include
int main()

register int i = 10; int *p = &i; error: address o
9 2

printf ("Val
ue of i:
sd", *p);
printf ("Add
ress of i:
su",

P);

3. Static Storage Class

The Static specifier gives the declared variable static storage class.
Static variables can be used within function or file.Unlike global variables,
static variables are not visible outside their function or file, but they
maintain their values between calls. The Static specifier has different
effects upon local and global variables. See the following flavours of
static specifier.

உ When static specifier is applied to a local variable inside a
function or block, the compiler creates permanent storage for it,
much as it creates storage for a global variable but static local
variable remains visible only to the function or block in which it is

Similar Question Papers