Thursday, December 25, 2008

Data Type Questions with Answers

Q1.What will be output of following program ?

void main()
{
char i=13;
clrscr();
while(i)
{
i++;
}
printf("%d",i);
getch();
}
Output: 0

Q2.What will be output :

void main()
{
float a= -3.3f;
int i;
unsigned char *p=&a;
for(int i=0;i<4;i++)
{
printf(“%d “,*p); p++;
}
}
Ans : Output : 52 52 83 192

Q3.What will be output:
void main()
{
int a=5,b=6,c=7;
printf(“%d,%d,%d”);
}
Ans:
Output: 7 6 5
Explanation:
Default sotrage class int a=5 is auto.Since it automatic variable it
will create in the stack area.It will store in the stack as:
Stack always follows LIFO datastructure.In the printf statement
name of variable is not written explicitly.So default output will
content of Stack which will be in the LIFO order i.e 7 6 5.
(memory map)

No comments:

Blog List