C Language - Storage Classes
You Are Here :: Home > C Language > Storage Classes- General Questions
43.
#include
int main(){
int i;
auto char c;
float f;
printf("%d %c %f",i,c,f);
return 0;
}
A.
0 0
B.
0
C.
1 1
D.
Garbage Garbage Garbage
Answer: Option D
Explanation:
Const Indicates that the Variable is of Constant Type and Cannot be modified.num = 10 attempts to modify num in Program Which is Illegal
44.
#include
int main(){
int i;
for(i=0;i<4;i++){
int a=20;
printf("%d",a);
a++;
}
return 0;
}
A.
24 24 24 24
B.
20 20 20 20
C.
16 16 16 16
D.
error
Answer: Option B
Explanation:
Variable declared inside the for loop block has scope only within that block. After the first iteration variable a becomes dead and it looses its incremented value. In second iteration variable a is again declared and initialized and so on.
45.
#include
int main(){
register int a=10;
int *p;
p=&a;
printf("%u",p);
}
A.
10
B.
2
C.
0
D.
compiletime error
Answer: Option D
Explanation:
46.
#include
int main(){
{
static int a=5;
printf("%d",a);
}
//printf("%d",a); variable a is not visible here.
return 0;
}
Answer: Option C
Explanation:
If we declared static variable locally then its visibility will within a block where it has declared.
47.
#include
void visit();
int main(){
int i=0;
{ //Opening inner block
static int a=5; //locally declaration
XYZ:; //Label of goto statement
printf("%d ",a);
a++;
i++;
} //closing inner block.
visit();
/* printf("%d",a); Variable a is not visible here but
it is alive. */
if(i<5)
goto XYZ;
return 0;
}
void visit(){
}
A.
5 5 5 5 5
B.
6 6 6 6 6
C.
5 6 7 8 9
D.
error
Answer: Option C
Explanation:
If we static variable has declared locally or globally its scope will always whole the program
48.
#include
char c;
int i;
float f;
char *str;
int main(){
printf("%d %d %f %s",c,i,f,str);
return 0;
}
A.
1.0000000
B.
0.0000000
C.
1 0 0.000000
D.
0 0 0.000000
Answer: Option D
Explanation:
Default initial value of extern integral type variable is zero otherwise null.
« previous
...
next »