First round (Qualifying round)
1. A variable can have multiple storage classes. (T/F)
2. Size of int in C is always 2 bytes. (T/F)
char *str ="multi" "media";
(i) 0,1, 2 .... 10
(ii) infinite loop
(iii) abnormal program termination
(iv) 0,1,2....... 32767
printf("%d %d %d %d",i,j,k,l);
(i) 1 2 -1 1
(ii) 0 1 -1 1
8. struct a
int tnp(int n)
static int i=1;
if(n>=5) return n;
The value returned by tnp(1) is
Multiple choice for these questions and answers will be displayed here
on 5 Sep 2008.
Second round (Programming round)
on a tree want to learn natural numbers. They start singing all natural numbers
in the increasing order starting from 1. When a number K is sung, K birds fly
away from the tree. If, at any second, the number of birds on the tree is
strictly less than the number which must be sung, the birds restart the game and
start singing the numbers from 1 again.
You are given an int ‘n’, the number of birds on the tree. Taking into account
that singing a number takes exactly one second, return the total time elapsed
before all birds fly away.
- n will be between 1 and 10^5, inclusive.
There is just one bird who flies at the first second.
One bird flies away at the first second, the other two at the next one.
At second 1, birds sing "one" and one of four birds flies away (with 3 birds
remaining on the tree). At second 2, birds sing "two" and two of three birds fly
away. At the third, the birds restart the game from 1 and the last bird flies
During the first four seconds the birds will count from 1 to 4, so (1 + 2 + 3 +
4) = 10 birds will fly away, with 4 birds left on the tree. The game will be
restarted from 1, so 1 and 2 birds will fly away on seconds 5 and 6
respectively. On second 7, the birds will restart the game again and the only
remaining bird will fly away.