Saturday, February 27, 2010

APTITUDE QUESTION IN GATE

I saw a question on previous year gate question paper that has attracted me very much.
HOW MANY FOUR DIGIT EVEN NUMBERS ARE THERE SUCH THAT THEIR DIGITS ARE DISTINCT?
Even number means their last digit is either 0,2,4,6 or 8
case 0:The first digit is a number from 1 to 9 because 0 is fixed and therefore 9 choices for first digit and 8 for the second and 7 for the third and last digit is fixed.According to combination number of four digit number ending with 0 is 9*8*7=504
care 2,4,6,8:This case is different because first digit cant be zero therefore 8*8*7=448 therefore for 2
4 6 and 8 we have 448*4=1792.Therefore in total 1792+504=2296 possibilities.Those who have doubt in this answer check it with the following C code which i did.

count=0
for(i=1;i<9;i++)
for(j=0;j<9;j++)
for(k=0;k<9;k++)
for(l=0;l<9;l++)

if(i!=j&&i!=k&&i!=l)
if(j!=k&&j!=l)
if(k!=l)
count=count+1;
This code will give 2296 as output.

No comments:

Post a Comment