sunil


{ City } hyd
< Country > india
* Profession * student
User No # 41629
Total Questions Posted # 0
Total Answers Posted # 2

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 21
Users Marked my Answers as Wrong # 8
Questions / { sunil }
Questions Answers Category Views Company eMail




Answers / { sunil }

Question { Wipro, 173398 }

write a program to swap Two numbers without using temp variable.


Answer

four Types with single statements:

1.b=(a+b)-(a=b);

2.a^=b^=a^=b;

3.a=a+b;
b=a-b;
a=a-b;

4.a=a*b;
b=a/b;
a=a/b;


rohanraju143@gmail.com from NIT Waramgal

Is This Answer Correct ?    18 Yes 7 No

Question { 18242 }

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW
IT COME ..

#include
#include
void main()
{
int k=20;
printf("%d%d%d%d",k,k++,++k,k);
getch();
}


Answer

answer is

22 21 21 20

printf .. executes from left hand side..


so first ..

printf("$d %d %d %d",k,K++,++k,k);

4.last k ie; 20
3.++k (pre) : 21
2.k++ (post) : 21 and then increamented
1.k : 22

answer is : 22 21 21 20

Is This Answer Correct ?    3 Yes 1 No