Storage class interview questions in c

Storage class interview questions in c programming


1. What is problem in following code?
void main(){
    int a=5;
static int i=a+5;
printf(“%d”,i);
}
2. Tell any five properties of auto variables?
3.
What is problem in following code?
void main(){
    register a,b,sum;
scanf(“%d%d”,&a,&b);
sum=a+b;
printf(“%d”,sum);
}
4. Can we declare same variables in two times globally?
5. Tell me something about extern variables.
6. What is difference between auto and static storage class?
8. What is data and code area of data segment?
9. What is problem in the following code?
void main(){
    extern int i;
    printf(“%d”,i);
}
int i=6;

9 comments:

Anonymous said...

how to find the answer?

rashi gupta said...

printf("%%%%");

output is %%


can anyone explain the reason for it........

Anonymous said...

@rashi %% is used to print a single % in printf
hence %%%% print 2 units of %.

Anonymous said...

can u print tayyab khan in form of star

Anonymous said...

what are storage classes and its ise?

Anonymous said...

storage class define the scope, life and in which segment the variable is actually stored in the main memory is defined by the storage class.
variables of auto storage class is strored in stack segment.
variables of register storage class are stored in cpu registers.
unintialized static and global variables are stored in BSS(block started by symbols ) segment and the initialized global and static variables are stored in data segment.

Anonymous said...

Q9 was a excellent question.

ranjith said...

void main(){
extern int i;
printf(“%d”,i);
}
int i=6;

answer:6
there is no problem in this questionn...

Maninder Singh said...

% acts as the delimiter