Learn Programming through Logical Thinking Series -1
This blog explains about Learn Programming through Logical Thinking Series -1 and is explained below :
_______________________________________________________________________________
In our Learn Logical Thinking and Programming Series -1, we are going to discuss about the below aptitude. This is one of the easiest logical thinking questions, usually asked in Aptitude rounds during interviews.
Aptitude:
1. The sum of age of 5 children born at interval of 3 years each is 50 years. Find out Who is the youngest child?
Solution:
Let us assume that, 1st child will be x, 2nd child will be x+3, 3rd child will be x+6, 4th child will be x+9 and
5th child will be x+12.
The given Clue is -Sum of ages of 5 children = 50
Thus, we can say that x+x+3+x+6+x+9+x+12 = 50
i.e.., 5x+30 = 50
x = (50 – 30)/5, which is 4.
2. The average age of A , B & C is 27 years . After joining D their average age become 28 then what will be the age of D .
SOLUTION :
The average age of A , B & C = 27 years .
Then the sum of their ages = A +B + C = 27 * 3
= 81 years .
So the average age of A , B , C & D will be 81 + D = 28 * 4
= 112 years
=> D = 112 – 81 = 31 years .
Thus the age of D = 31 years .
Now We will find this can be found using Java Program below.
Learn Logical Thinking through Programming:
public class YoungestChild {
public static void main(String[] args) {
int noOfchildren=5;
int age=50;
int interval=3;
int min=0;
for(int i=0;i<noOfchildren;i++)
{
min=min+(interval*i);
}
min=(age-min)/noOfchildren;
System.out.println(“Youngest age:”+ min);
}
}
OUTPUT:
Youngest age: 4
_______________________________________________________________________________________