Question
int i=10;
main()
{
extern int i;
{
int i=20;
{
const volatile unsigned i=30;
printf("%d",i);
}
printf("%d",i);
}
printf("%d",i);
}
Question Submitted By :: Susie
I also faced this Question!!
Rank
Answer Posted By
Re: int i=10;
main()
{
extern int i;
{
int i=20;
{
const volatile unsigned i=30;
printf("%d",i);
}
printf("%d",i);
}
printf("%d",i);
}
Answer
# 1
Answer :
30,20,10
Explanation:
'{' introduces new block and thus new scope. In the
innermost block i is declared as,
const volatile unsigned
which is a valid declaration. i is assumed of type int. So
printf prints 30. In the next block, i has value 20 and so
printf prints 20. In the outermost block, i is declared as
extern, so no storage space is allocated for it. After
compilation is over the linker resolves it to global
variable i (since it is the only variable visible there). So
it prints i's value as 10.
Susie
Other C Code Interview Questions
Question Asked @ Answers #include <stdio.h>
main()
{
char * str = "hello";
char * ptr = str;
char least = 127;
while (*ptr++)
least = (*ptr<least ) ?*ptr :least;
printf("%d",least);
} 1 main()
{
int i=5,j=6,z;
printf("%d",i+++j);
} 1 void main()
{
char a[]="12345\0";
int i=strlen(a);
printf("here in 3 %d\n",++i);
} 1 programming in c lanugaue programm will errror error with
two header file one as stdio.h and other one is conio.h 1 main()
{
int i=5;
printf("%d",++i++);
} 1 Give a very good method to count the number of ones in a 32
bit number.
(caution: looping through testing each bit is not a solution) Microsoft 5 int i=10;
main()
{
extern int i;
{
int i=20;
{
const volatile unsigned i=30;
printf("%d",i);
}
printf("%d",i);
}
printf("%d",i);
} 1 How will you print % character?
a. printf(“\%”)
b. printf(“\\%”)
c. printf(“%%”)
d. printf(“\%%”) HCL 1 Write a program that find and print how many odd numbers in
a binary tree 1 main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
} 1 How to swap two variables, without using third variable ? HCL 47 Find your day from your DOB? Microsoft 12 main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
} 1 main( )
{
int a[ ] = {10,20,30,40,50},j,*p;
for(j=0; j<5; j++)
{
printf(“%d” ,*a);
a++;
}
p = a;
for(j=0; j<5; j++)
{
printf(“%d ” ,*p);
p++;
}
} 1 main()
{
int x=5;
clrscr();
for(;x<= 0;x--)
{
printf("x=%d ", x--);
}
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. –3, -1, 1, 3, 5 HCL 1 Write a prog to accept a given string in any order and flash
error if any of the character is different.
For example : If abc is the input then abc, bca, cba, cab
bac are acceptable, but aac or bcd are unacceptable. Microsoft 5 Write a function to find the depth of a binary tree. Adobe 8 Extend the sutherland-hodgman clipping algorithm to clip
three-dimensional planes against a regular paralleiepiped IBM 1 write a program in c to merge two array 1 void pascal f(int i,int j,int k)
{
printf(“%d %d %d”,i, j, k);
}
void cdecl f(int i,int j,int k)
{
printf(“%d %d %d”,i, j, k);
}
main()
{
int i=10;
f(i++,i++,i++);
printf(" %d\n",i);
i=10;
f(i++,i++,i++);
printf(" %d",i);
} 1 For more C Code Interview Questions Click Here