Question 1 |
What is the output of the following program?
#include < stdio.h >
int main()
{
int a=10, b=20;
int *p;
p=&a;
*p=b;
a=35;
*p+=5;
b=*p;
p=&b;
*p=a;
printf("%d %d",a,b);
return 0;
}
10 20 | |
10 40 | |
40 40 | |
40 10 |
Question 1 Explanation:

OUTPUT : 40 40


Click Here to Practice ALL Previous MOCK TEST FREE
Use Comment Box for your doubts or post similar trickey Questions
Question 2 |
What is the output of the following program?
#include < stdio.h >
int main()
{
int a[]={1,2,3,4,5};
int b[]={1,2,3,4,5};
if(a==b)
{
printf("IITB");
}
else
{
printf("IISC");
}
return 0;
}
IITB | |
IISC | |
Compiler error | |
Output depends on Compiler |
Question 2 Explanation:


If statement will compare the base address of two arrays a and b,and they are not same.
So condition becomes false and program prints no.
OUTPUT : IISC







Click Here to Practice ALL Previous MOCK TEST FREE
Use Comment Box for your doubts or post similar trickey Questions
Question 3 |
What is the output of the following program?
#include < stdio.h >
int main()
{
int a[5]={1,2,3,4,5};
int *p;
p=a;
printf("%d",*p++);
printf("%d",(*p)++);
printf("%d",*p);
printf("%d",*++p);
printf("%d",++*p);
return 0;
}
1 2 3 3 4 | |
1 2 2 3 4 | |
1 2 3 4 4 | |
Compiler error |
Question 3 Explanation:


OUTPUT : 12334







Click Here to Practice ALL Previous MOCK TEST FREE
Use Comment Box for your doubts or post similar trickey Questions
Question 4 |
What is the output of the following program?
#include < stdio.h >
int main()
{
int a[5]={1,2,3,4,5};
int *p;
p=a;
printf("%d",*a++);
printf("%d",(*a)++);
printf("%d",*a);
printf("%d",*++a);
printf("%d",++*a);
return 0;
}
1 2 3 3 4 | |
1 1 2 3 4 | |
1 2 3 4 5 | |
Compiler error |
Question 4 Explanation:
When we declare int a[5]={1,2,3,4,5}; in c program. "a" becomes the constant pointer. It means that, we can not modify the "a" in program.
In the above program two statements
printf("%d",*a++);
printf("%d",*++a);
tries to modify the "a".
Hence, it's a compiler error.
Click to Join Our Telegram Group for Latest Update of MOCK TEST 





Click Here to Practice ALL Previous MOCK TEST FREE
Use Comment Box for your doubts or post similar trickey Questions
In the above program two statements
printf("%d",*a++);
printf("%d",*++a);
tries to modify the "a".
Hence, it's a compiler error.







Click Here to Practice ALL Previous MOCK TEST FREE
Use Comment Box for your doubts or post similar trickey Questions
Question 5 |
What is the output of the following program?
#include < stdio.h >
int main()
{
int a[5]={1,2,3,4,5};
int *p;
p=a;
printf("%d",*(p+2));
printf("%d",*(a+2));
p++;
printf("%d",*p);
printf("%d",*a);
return 0;
}
3 3 2 2 | |
3 3 2 1 | |
3 3 Gabage 1 | |
3 3 Gabage 2 |
Question 5 Explanation:


OUTPUT : 3321







Click Here to Practice ALL Previous MOCK TEST FREE
Use Comment Box for your doubts or post similar trickey Questions
There are 5 questions to complete.
Q3. Doubt.
*(1008) gives 3.
*(1004) gives 3.
*(1008) has value 4. But gives 3!
*(1008) is 3 as per the answer. At last line ++*p it becomes 4.
Never mind.
Question 7.
Explanation doubt in last but line.
p=p+3; //last update of variable p e.i base address is 1002+3*sizeof(char) e.i 1005.
printf(“%d”,p+2); //does not update p, I guess.
so, printf(“%c”,p[-3]) will be the base address 1005-3*sizeof(char)=1002. So *(1002) gives “a”.
Thank You Manoj,
We have updated the answer.