Oct 28, 2010

Find the output.

main()
{
int i=0;
while(+(+i--)!=0)
i-=i++;
printf("%d",i);
}



Answer:
-1


Explanation:
Unary + is the only dummy operator in C. So it has no effect on the expression and now the while loop is, while(i--!=0) which is false and so breaks out of while loop. The value –1 is printed due to the post-decrement operator.

Oct 27, 2010

What is the relation?

P's father is Q's son. M is paternal uncle of P and N is the brother of Q. How is N related to M?


Answer:
N is paternal uncle of M.

Find out the missing no. in the series..

Find the next no. of the following series:
(i) 3,10,101,?
(ii) 1,2,4,9,28,?
(iii) 24,60,120,210,?


Answer: 
(i) 3,10,101,10202
(ii) 1,2,4,9,28,125
(iii) 24,60,120,210,336


Explanation: 
(i) 3, (3*3+1), (10*10+1), (101*101=1)..
(ii) (0!+0), (1!+1), (2!+2), (3!+3), (4!+4), (5!+5)..
(iii) (3^3-3), (4^3-4), (5^3-5), (6^3-6)..

Find the output.

Try this..
main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
What is the output of above program??

Answer:
hai

Explanation:
The first printf statement prints 'ab'
The second printf statement prints 'asi'(bcoz \b backspace cmd prints next to 'a' and overwrites 'b')
The third printf statement prints 'hai' (bcoz \r return cmd overwrites on 'asi')

How many times do they toll?

Three bells toll together at intervals of 4,6 and 8 seconds. In two minutes how many times do they toll together???

Answer:
5 times.
Explanation:
The LCM of 4,6 and 8 is 24
Given 2 minutes i.e 120 seconds
No. of times = 120(time in sec)/24(LCM) = 5 times

Oct 26, 2010

Find the output.

main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
}
what's the output??


Answer: 
i = -1, +i = -1

Explanation: 
   Unary + is the only dummy operator in C. Where-ever it comes you can
just ignore it just because it has no effect in the expressions (hence the
name dummy operator).

Oct 25, 2010

What is the relation?

A father is 4 times his son's age. And in 30 years son's age will be half of his father's age. How old are the father and son now???

Answer: 
Son's age : 15
Father's age : 60


Explanation:
The ratio of the father and son's age is now 4 to 1 and 30 years from now it will be 2 to 1. The period of thirty years equals the difference of the two ratios or 2 to 1. Therefore, 30*2 = 60, the father's age and (1/2) * 30 = 15, the son's age.

Find out no. of days.

A is thrice as good as workman as B and therefore is able to finish a job in 60 days less than B. Working together, they can do it in??

Answer:
45(or)221days.
22




Explanation:
Ratio of times taken by A and B = 1 : 3.
The time difference is (3 - 1) 2 days while B take 3 days and A takes 1 day.
If difference of time is 2 days, B takes 3 days.
If difference of time is 60 days, B takes3x 60= 90 days.
2
So, A takes 30 days to do the work.
A's 1 day's work =1
30
B's 1 day's work =1
90
(A + B)'s 1 day's work =1+1=4=2
30909045
 A and B together can do the work in45= 221days.
22

Oct 24, 2010

What is the journey length?

A train travels at an average speed of 40kmph to reach its destination. But at d speed of 35kmph it reaches 15min late. wat's the journey length?

Answer: 
70km

Oct 23, 2010

What is the relation?

A girl introduces a boy that he is my father's mother's son-in-law's son. How the girl related to the boy?

Answer: 
Cousin