Thursday, 8 August 2013

TCS Placement Paper



Latest Sample Placement Paper Of TCS For Year-2009-10,2010-2011,2011,2012, (Aptitude, English) TCS (TECH PAPER) TCS, C, C++ Language Paper TCS Technical C,C++ Questions Given Below: TCS last 12 years solved question papers, TCS previous years free solved placement papers, TCS Technical Hr interview procedure, TCS free on line mock Test, TCS largest collection of  Model question papers for practice, TCS original pattern and sample placement papers, TCS free campus recruitment on line question papers, TCS free on line mock Test, TCS sample practice question papers, TCS 2008,2009,2010,2011,2012..previous years solved question papers,TCS latest test pattern TCS free placement papers TCS Off and On campus recruitment procedure...

TCS C Aptitude: Questions

1. The C language terminator is 
(a) semicolon (b) colon (c) period (d) exclamation mark 

2. What is false about the following -- A compound statement is 
(a) A set of simple statements (b) Demarcated on either side by curlybrackets 
(c) Can be used in place of simple statement (d) A C function is not a compound statement. 

3. What is true about the following C Functions 
(a) Need not return any value (b) Should always return an integer 
(c) Should always return a float (d) Should always return more than one value 

4. Main must be written as 
(a) The first function in the program (b) Second function in the program 
(c) Last function in the program (d) Any where in the program 

5. Which of the following about automatic variables within a function is correct ? 
(a) Its type must be declared before using the variable (b) They are local 
(c) They are not initialized to zero (d) They are global 


6. Write one statement equivalent to the following two statements: x=sqr(a);return(x); Choose from one of the alternatives 
(a) return(sqr(a)); (b) printf("sqr(a)"); 
(c) return(a*a*a); (d) printf("%d",sqr(a)); 

7. Which of the following about the C comments is incorrect ? 
(a) Comments can go over multiple lines 
(b) Comments can start any where in the line 
(c) A line can contain comments with out any language statements 
(d) Comments can occur within comments 

8. What is the value of y in the following code? 
x=7; 
y=0; 
if(x=6) y=7; 
else y=1; 
(a) 7 (b) 0 (c) 1 (d) 6 

9. Read the function conv() given below 
conv(int t) 
int u; 
u=5/9 * (t-32); 
return(u); 
What is returned 
(a) 15 (b) 0 (c) 16.1 (d) 29 

10. Which of the following represents true statement either x is in the range of 10 and 50 or y is zero 
(a) x >= 10 && x <= 50 || y = = 0 (b) x<50 
(c) y!=10 && x>=50 (d) None of these 


11. Which of the following is not an infinite loop ? 
(a) while(1)\{ ....} (b) for(;;){...} 
(c) x=0; (d) # define TRUE 0 
do{ /*x unaltered within the loop*/ ... 
.....}while(x = = 0); while(TRUE){ ....} 

12. What does the following function print? 
func(int i) 
if(i%2)return 0; 
else return 1; 
main() 
int =3; 
i=func(i); 


i=func(i); 
printf("%d",i); 
(a) 3 (b) 1 (c) 0 (d) 2 

13. How does the C compiler interpret the following two statements 
p=p+x; 
q=q+y; 

(a) p= p+x; (b) p=p+xq=q+y; (c) p= p+xq; (d) p=p+x/q=q+y; 
q=q+y; q=q+y; 
For questions 14,15,16,17 use the following alternatives: 
a. int b. char c. string d. float 

14. '9' 

15. "1 e 02" 

16. 10e05 

17. 15 

18. Read the following code 
# define MAX 100 
# define MIN 100 
if(x>MAX) 
x=1; 
else if(x<MIN) 
x=-1; 
x=50; 
if the initial value of x=200,what is the value after executing this code? 
(a) 200 (b) 1 (c) -1 (d) 50 

19. A memory of 20 bytes is allocated to a string declared as char *s then the following two
statements are executed: 
s="Entrance" 
l=strlen(s); 
what is the value of l ? 
(a)20 (b)8 (c)9 (d)21 

20. Given the piece of code 
int a[50]; 
int *pa; 
pa=a; 
To access the 6th element of the array which of the following is incorrect? 
(a) *(a+5) (b) a[5] (c) pa[5] (d) *(*pa + 5} 

21. Consider the following structure: 

struct num nam 
int no; 
char name[25]; 
struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}}; 
..... 
..... 
printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1); 
What does the above statement print? 
(a) 8,9 (b) 9,9 (c) 8,8 (d) 8, unpredictable value 

22. Identify the in correct expression 
(a)a=b=3=4; (b)a=b=c=d=0; (c)float a=int b= 3.5; (d)int a; floatb;a=b=3.5; 

23. Regarding the scope of the varibles;identify the incorrect statement: 
(a) automatic variables are automatically initialized to 0 (b) static variables are areautomatically initialized to 0 
(c) the address of a register variable is not accessible (d) static variables cannot be initialized with any expression 

24. cond 1?cond 2?cond 3?:exp 1:exp 2:exp 3:exp 4; is equivalent to which of the following? 
(a) if cond 1 
exp 1; 
else if cond 2 
exp 2; 
else if cond 3 
exp 3; 
else exp 4; 

(b) if cond 1 
if cond 2 
if cond 3 
exp 1; 
else exp 2; 
else exp 3; 
else exp 4; 

(c) if cond 1 && cond 2 && cond 3 
exp 1 |exp 2|exp 3|exp 4; 

(d) if cond 3 
exp 1; 
else if cond 2 exp 2; 
else if cond 3 exp 3; 
else exp 4; 

25. The operator for exponentiation is 
(a) ** (b) ^ (c) % (d) not available 

26. Which of the following is invalid 

(a) a+=b (b) a*=b (c) a>>=b (d) a**=b 

27. What is y value of the code if input x=10 
y=5; 
if (x==10) 
else if(x==9) 
else y=8; 
(a)9 (b)8 (c)6 (d)7 

28. What does the following code do? 
fn(int n, int p, int r) 
static int a=p; 
switch(n) 
case 4:a+=a*r; 
case 3:a+=a*r; 
case 2:a+=a*r; 
case 1:a+=a*r; 
(a) computes simple interest for one year (b) computes amount on compoundinterest for 1 to 4 years 
(c) computes simple interest for four year (d) computes compound interest for 1year 

29. 
a=0; 
while(a<5) 
printf("%d\n",a++); 
How many times does the loop occurs? 
(a) infinite (b)5 (c)4 (d)6 

30. How many times does the loop iterated ? 
for(i=0;i=10;i+=2) 
printf("Hi\n"); 
(a)10 (b) 2 (c) 5 (d) None of these 

31. What is incorrect among the following 
A recursive function 
(a) calls itself (b) is equivalent to a loop 
(c) has a termination condition (d) does not have a return value at all 

32. Which of the following go out of the loop if expn 2 becoming false 
(a) while(expn 1)\{...if(expn 2)continue;} (b) while(!expn
1)\{if(expn 2)continue;...} 
(c) do{..if(expn 1)continue;..}while(expn 2); (d) while(!expn
2)\{if(expn 1)continue;..\} 

33. Consider the following program 
main() 
{
unsigned int i=10; 
while(i>=0) 
printf("%u",i) 
i--; 
How many times the loop will get executed 
(a)10 (b)9 (c)11 (d) infinite 

34.Pick out the odd one out 
(a) malloc() (b) calloc() (c) free() (d) realloc() 

35.Consider the following program 
main() 
int a[5]={1,3,6,7,0}; 
int *b; 
b=&a[2]; 
The value of b[-1] is 
(a) 1 (b) 3 (c) -6 (d) none 

36. # define prod(a,b)=a*b 
main() 
int x=2; 
int y=3; 
printf("%d",prod(x+2,y-10)); 
the output of the program is 
(a) 8 (b) 6 (c) 7 (d) None 

37.Consider the following program segment 
int n,sum=1; 
switch(n) 
case 2:sum=sum+2; 
case 3:sum*=2; 
break; 
default:sum=0; 
If n=2, what is the value of sum 
(a) 0 (b) 6 (c) 3 (d) None of these 

38. Identify the incorrect one 
1.if(c=1) 
2.if(c!=3) 
3.if(a<b)then 
4.if(c==1) 

(a) 1 only (b) 1&3 (c) 3 only (d) All of the above 

39. The format specified for hexa decimal is 
(a) %d (b) %o (c) %x (d) %u 

40. Find the output of the following program 
main() 
int x=5, *p; 
p=&x 
printf("%d",++*p); 
(a) 5 (b) 6 (c) 0 (d) none of these 

41.Consider the following C code 
main() 
int i=3,x; 
while(i>0) 
x=func(i); 
i--; 
int func(int n) 
static sum=0; 
sum=sum+n; 
return(sum); 
The final value of x is 
(a) 6 (b) 8 (c) 1 (d) 3 

42. Int *a[5] refers to 
(a) array of pointers (b) pointer to an array (c) pointer to apointer (d) none of these 


Latest Sample Placement Paper Of TCS For Year-2009-10 (Aptitude, English) 


1. (38 x 142) ÷ (4096) =? 

1) 337.25 -Answer
2) 269.8 
3) 490 
4) 84.3125 
5) None of these 

2. 3 + 33.3 + 3.03 + 333 =? 

1) 666 
2) 636.33 
3) 372.33 -Answer
4) 672.66 
5) None of these 

3. (17.52)2 =?

1) 280.9504 
2) 290.5904 
3) 306.9504 -Answer
4) 280.5904 
5) None of these 

4. (37% of 2370) – (41% of 2105) =? 

1) 13.85 -Answer
2) 12.56 
3) 13.10 
4) 12.15 
5) None of these 

Directions (Q. 5-14): 

In the following passage there are blanks, each of which has been numbered. 
These numbers are printed below the passage and against each five words are suggested, one of which fits the blank appropriately. Find out the appropriate words. 
It is a 5 that Communists are opposed toeconomic reforms. The fact of the life is that Communists are the most 6 fighters for economic reforms, the reforms that lead to self-reliant and democratic economic development
with social justice. To term the market-oriented changes as reform is a 7. The development strategy 8 under Structural Adjustment and dictated by the World Bank, IMF and WTO is a strategy for the 9 development of capitalism under which the working people, who are the main productive force, are made 10, kept unemployed, thrown out of jobs, and so on. It has no social relevance. In the phase of globalization, no country can develop in 11 and entry of the foreign capital can not be12 altogether. Integration with world economy has to ensure the free and speedy 13 of the national economy. Foreign capital has to be allowed in the areas where we really need huge investment, which our resources cannot meet, and where we need technology, not available in the country. Economic14 should not mean license for plunder by MNCs. 

5. 
1) problem 
2) mysticism 
3) curiosity 
4) misconception -Answer
5) mistake 

6. 
1) liberal 
2) demanding 
3) strident -Answer
4) detrimental 
5) horrible 

7. 
1) misnomer -Answer
2) terrible 
3) danger 
4) tragedy 
5) shame 

8. 
1) reached 
2) verified 
3) assembled 
4) hurled 
5) envisaged -Answer

9. 
1) westernised 
2) unfettered -Answer
3) gross 
4) accumulated 
5) astounding 


10. 
1) labourers 
2) culprit 
3) redundant -Answer
4) escapists 
5) icons 

11. 
1) unison 
2) liberalisation 
3) coalition 
4) association 
5) isolation -Answer

12. 
1) forced 
2) loaded 
3) denied -Answer
4) stated 
5) scrutinised 

13. 
1) development -Answer
2) empowerment 
3) unity 
4) mobilisation 
5) cohesion 

14. 
1) growth 
2) potential 
3) strategy 
4) reforms -Answer
5) vitality 
Directions (Q. 15-24): Given below are two passages. Read them carefully and answer the questions given below them. 
Certain words are given in bold to help you to locate them while answering some of the questions. 

Passage – I 
Americans have a variety of superstitions like walking under a ladder, a black cat crossing your path and the number 13, none of which seem to have a logical reason for being. However, there are no serious taboos attached to them. Individuals may have an array of sensitivities based on their personal beliefs. If you do offend someone inadvertently, a sincere apology will usually go a long way toward making amends. The one sensitivity that almost all Americans have is about slights to their country. Either complaining about the US or expressing an attitude that your culture is superior can cause Americans to take offence. Americans do possess a great deal of culture arrogance, and think that their way is the only right way. They think that the US is the best place on earth, otherwise why would everybody by trying to get here? Whether you agree or not, remember that you are a guest in the US and it would be rude for a guest to insult his host 

15. Which of the following can be presumed about Americans regarding superstition? 
1) It is a cultural custom for them to believe in superstitions. 
2) They can satisfy you by placing arguments about the validity of superstitions. 
3) Americans cannot justify their adherence to superstitions. -Answer
4) Americans are highly superstitious people. 
5) None of these 

16. If you offend an American inadvertently, a sincere apology will 
1) take a long time to repair the damage. 
2) not necessarily by enough to amend it. 
3) be turned down. 
4) succeed in making amends. -Answer
5) None of these 

17. Americans feel usually offended whenever there is a(n) 
1) argument posed before them. -Answer
2) rude remark against their culture. -Answer
3) threat to their sovereignty. 
4) attack on their religion. 
5) None of these 

18. What makes the Americans feel that their country is the best in the world? 
1) mad rush of people from other countries to America 
2) the best facilities available there 
3) their culture and custom which they feel is the best in the world 
4) the economic superiority of America 
5) None of these 

19. What is the antonym of the word inadvertently as given in bold in the passage? 
1) intentionally -Answer
2) occasionally 
3) unwittingly 
4) avowedly 
5) adroitly 


Passage – II 
Population is one resource that never depletes and is a living development parameter. But it is at times interpreted as a hindering factor for development. This happens because population is both a consumer and producer. There are two schools of thought. One which treats population as a resource, and the other as a burden to the society. The truth, in fact, lies somewhere in between. The interplay of factors responsible for population growth and those for development decide the resourcefulness of population. 

20. Why is it said that population is one resource that never depletes? 
1) because other resources deplete 
2) because population is an ever-increasing phenomenon -Answer
3) because population is seen as a resource 
4) because it is an easily available commodity 
5) None of these 

21. Why population is at the same time treated as a resource and also as a burden to the society? 
1) because population is the creator and at the same time it is also the user -Answer
2) because a less number of people are engaged in production and a large number of people are dependent on it 
3) because population is not always a producer but it is always a consumer 
4) when the growth of population is checked it is a resource and when it increases rapidly it is burden to the society 
5) None of these 

22. The resourcefulness of population can be decided by 
(i) skilled manpower (ii) scale of development (iii) population control measures (iv) scale of population growth 
1) All of the above 
2) Only (i), (ii) and (iii) 
3) Only (i) and (iii) -Answer
4) Only (ii) and (iv) 
5) None of these 

23.Which of the following is true in context of the passage? 
1) It is not necessary that the population always grows. 
2) Population is burdensome. 
3) Most of the natural resources are exhaustible. -Answer
4) Population is a big consumer and a meager producer. 
5) None of these 

24.What will be the synonym of the word depletes as given in bold in the passage? 
1) disappears 
2) sustains 
3) worsens 
4) evades 
5) reduces -Answer

25. – 65 x39 + 335 =? 
1) – 849225 
2) – 2200 -Answer
3) – 2870 
4) 2870 
5) None of these 

TCS TCS Model Question Paper Given Below 

TCS Questions 
Note: 1 mark will be deducted for every 3 wrong answers Quantitative/aptitude test (35 questions, 80 minutes) 

1. A Roman was born the first day of the 35th year before Christ and died the first day of the 35th year after Christ. How many years did he live?
(a) 70 (b) 69 (c) 71 (d) 72 

2. A horse starts to chase a dog that has left the stable two hours earlier. The horse runs at an average speed of 2km/hr. It crosses a 10-metre road, two small ponds 3 metres deep, and finally runs along two small streets of 200 metres long. After traveling 6 hrs, 2hrs after sunset, it catches the dog. Compute the speed of the dog in Km/hr?
(a) 20 (b) 22 (c) 16.5 (d) 18.5 

3. Adam sat with his friends in the Chinnaswamy stadium at Madurai to watch the 100 metres running race organized by the Asian Athletics Association. Five rounds were run. After every round half the teams were eliminated. Finally, one team wins the game. How many teams participated in the race?
(a) 30 (b) 32 (c) 41 (d) 54 

4. If an airplane starts at point R and travels 14 miles directly north to S, then 48 miles directly east to T, what is the straight-line distance (in miles) from T to R?
(a) 25 (b) 34 (c) 50 (d) 2500 

5. A scientist was researching into animal behavior in his laboratory. He was very interested in studying the behavior of bears. He travelled a mile to the north and reached the north pole.There he saw a bear. He then followed the bear for an 1 hour to the east with a speed of 2km/hr. After that he travelled south and reached his laboratory in 2 hours. What was the colour of the bear?
(a) Black (b) White (c) Red (d) Blue 


6. A garrison of 3300 men has provisions for 32 days when supplied at the rate of 850 g per head. At the end of 7 days, a reinforcement arrives, and it is found that the provisions can last for 17 days more when supplied at the rate of 825 g per head. What is the strength of the reinforcement?
(a) 1700 (b) 1000 (c) 3000 (d) 2700 

7. Two unemployed young men decided to start a business together. They pooled in their savings, which came to Rs. 2,000. They were both lucky, their business prospered and they were able to increase their capital by 50 per cent every three years. How much did they have in all at the end of eighteen years?
(a) Rs. 22,781.25 (b) Rs. 24,150.25 (c) Rs. 28,140.50 (d) Rs. 18,000 

8. A man divides Rs.8600 among 5 sons, 4 daughters and 2 nephews. If each daughter receives four times as much as each nephew, and each son receives five times as much as each nephew, how much does each aughter receive?
(a) Rs.800 (b) Rs.600 (c) Rs.200 (d) Rs.700 

9. A train starts full of passengers. At the first station, it drops one-third of the passengers and takes 280 more. At the second station, it drops one-half of the new total and takes 12 more. On arriving at the third station, it is found to have 248 passengers. Find the number of passengers in the beginning.
(a) 240 (b) 248 (c) 280 (d) 288 

10. A manufacturer undertakes to supply 2000 pieces of a particular component at Rs.25 per piece. According to his estimates, even if 5% fail to pass the quality tests, then he will make a profit of 25%. However, as it turned out, 50% of the components were rejected. What is the loss to the manufacturer?
(a) Rs.12000 (b) Rs.13000 (c) Rs.14000 (d) Rs.15000 

11. In Tnagar many buildings were under residential category. for buildings they number as 1 to 100. For shops, corporation numbered between 150 and 200 only prime numbers. howmany time 6 will appear in building numbering?
(a) 10 (b) 20 (c) 8 (d) 19 

12. 6 persons standing in queue with different age group, after two years their average age will be 43 and seventh person joined with them. hence the current average age has become45. find the age of seventh person?
(a) 69 (b) 70 (c) 40 (d) 45 

13. 3, 22 , 7, 45, 15, ? , 31
(a) 45 (b) 90 (c) 91 (d) 35 

14. Which is the smallest no divides 2880 and gives a perfect square?
(a) 1 (b) 2 (c) 5 (d) 6 

15. One grandfather has three grandchildren, two of their age difference is 3, eldest child age is 3 times youngest childs age and eldest childs age is two times of sum of other two children. What is the age of eldest child?
(a) 5 (8) 10 (c) 8 (d) 15 

16. It is dark in my bedroom and I want to get two socks of the same color from my drawer, which contains 24 red and 24 blue socks. How many socks do I have to take from the drawerto get at least two socks of the same color?
(a) 2 (b) 3 (c) 48 (d) 25 

17. 23 people are there, they are shaking hands together, how many hand shakes possible, if they are in pair of cyclic sequence.
(a) 22 (b) 23 (c) 44 (d) 46 

18. There are 10 reading spots in a room. Each reading spot has a round table. Each round table has 4 chair. If different no of persons are sitting at each reading spot. And if there are 10 persons inside the room then how many reading spots donot have atleast a single reader.
(1) 5 (2) 6 (3) 7 (4) None 

19. Middle earth is a fictional land inhabited by Hobbits, Elves, dwarves and men. The Hobbits and the Elves are peaceful creatures who prefer slow, silent lives and appreciate nature and art. The dwarves and the men engage in physical games. The game is as follows .
A tournol is one where out of the two teams that play a match, the one that loses get eliminated. The matches are played in different rounds where in every round , half of the teams get eliminated from the tournament. If there are 8 rounds played in a knock-out tournol how many matches were played?
(a) 257 (b) 256 (c) 72 (d) 255 

20. There are two water tanks A and B, A is much smaller than B. While water fills at the rate of one litre every hour in A, it gets filled up like 10, 20, 40, 80, 160... in tank B. ( At the end of first hour, B has 10 litres, second hour it has 20, and so on). If tank B is 1/32 filled after 21 hours, what is the total duration required to fill it completely?
(a) 26 hrs (b) 25 hrs (c) 5 hrs (d) 27 hrs 

21. A man jogs at 6 mph over a certain journey and walks over the same route at 4 mph. What is his average speed for the journey?
(a) 2.4 mph (b) 4 mph (c) 4.8 mph (d) 5 mph 

22. A pizza shop, there were 2 kinds of pizzas available. But now they have introduces 8 new types, a person buy two different type pizzas of new type in how many ways he can select?28
(a) 24 (b) 43 (c) 56 (d) 58 

23. A box of 150 packets consists of 1kg packets and 2kg packets. Total weight of box is 264kg. How many 2kg packets are there?
(a) 100 (b) 114 (c) 200 (d) 208 

24. A man, a woman, and a child can do a piece of work in 6 days. Man only can do it in 24 days. Woman can do it in 16 days and in how many days child can do the same work?
(a) 8 (b) 14 (c) 16 (d) 18 

25. A bus started from bus stand at 8.00a m and after 30 min staying at destination, it returned back to the bus stand. The destination is 27 miles from the bus stand. The speed of the bus 50 percent fast speed. At what time it returns to the bus stand.
(a) 11a.m (b) 12a.m (c) 10a.m (d) 10.30p.m 


26. 2 oranges, 3 bananas and 4 apples cost Rs.15. 3 oranges, 2 bananas, and 1 apple costs Rs 10. What is the cost of 3 oranges, 3 bananas and 3 apples?
(a) Rs10 (b) Rs15 (c) Rs20 (d) Rs25 

27. If on an item a company gives 25% discount, they earn 25% profit. If they now give 10% discount then what is the profit percentage.
(a) 40% (b) 55% (c) 35% (d) 30% 

28. Two trains move in the same direction at 50 kmph and 32 kmph respectively. A man in the slower train observes the 15 seconds elapse before the faster train completely passes by
him. What is the length of faster train?
(a) 100m (b) 75m (c) 120m (d) 50m 

29. A man spends half of his salary on household expenses, 1/4th for rent, 1/5th for travel expenses, the man deposits the rest in a bank. If his monthly deposits in the bank amount 50,
what is his monthly salary?
(a) Rs.500 (b) Rs.1500 (c) Rs.1000 (d) Rs. 900 

30. It was Sunday on Jan 1, 2006. What was the day of the week Jan 1, 2010
(a) Sunday (b) Saturday (c) Friday (d) Wednesday 

31. In how many different ways can the letters of the word 'LEADING' be arranged in such a way that the vowels always come together?
(a) 360 (b) 480 (c) 720 (d) 5040 

32. The captain of a cricket team of 11 members is 26 years old and the wicket keeper is 3 years older. If the ages of these two are excluded, the average age of the remaining players isone year less than the average age of the whole team. What is the average age of the team?
(a) 23 years (b) 24 years (c) 25 years (d) None of these 

33. Six bells commence tolling together and toll at intervals of 2, 4, 6, 8 10 and 12 seconds respectively. In 30 minutes, how many times do they toll together?
(a) 4 (b) 10 (c) 15 (d) 16 

34. The difference of two numbers is 1365. On dividing the larger number by the smaller, we get 6 as quotient and the 15 as remainder. What is the smaller number?
(a) 240 (b) 270 (c) 295 (d) 360 

35. In a flight of 600 km, an aircraft was slowed down due to bad weather. Its average speed for the trip was reduced by 200 km/hr and the time of flight increased by 30 minutes. The
duration of the flight is:
(a) 1 hour (b) 2 hours (c) 3 hours (d) 4 hours 

TCS Model 1 
1. (1/2) of a number is 3 more than the (1/6) of the same number?
a) 6 b) 7 c) 8 d) 9 
Solution:
Let the number be x,
((1/2)*x)=3+(1/6)*x,
Then solve x = 9. 

2. (1/3) of a number is 3 more than the (1/6) of the same number?
a) 6 b) 16 c) 18 d) 21 

3. (1/3) of a number is 6 more than the (1/6) of the same number?
a) 6 b) 18 c) 36 d) 24 

4. (2/3) of a number is 4 more than the (1/6) of the same number?
a) 6 b) 8 c) 36 d) 24 

5. (1/3) of a number is 5 more than the (1/6) of the same number?
a) 6 b) 36 c) 30 d) 72 

TCS Model 2:

1. There are two water tanks A and B, A is much smaller than B. While water fills at the rate of 1 liter every hour in A, it gets filled up like, 10, 20, 40, 80, 160 in tank B. (At the end of first hour, B has 10 liters, second hour it has 20 liters and so on). If tank B is 1/32 filled of the 21 hours, what is total duration of hours required to fill it completely?
a) 26 B)25 c)5 d)27 
Solution: for every hour water in tank in B is doubled, 
Let the duration to fill the tank B is x hours.
x/32 part of water in tank of B is filled in 21 hours, 
Next hour it is doubled so, 
2*(x/32) part i.e (x/16) part is filled in 22 hours,
Similarly (x/8)th part in 23 hours,(x/4)th part is filled in 24 hours, 
(x/2)th part is filled in 25 hours, (x)th part is filled in 26 hours
So answer is 26 hours. 

2. There are two pipes A and B. If A filled 10 liters in an hour, B can fill 20 liters in same time. Likewise B can fill 10, 20, 40, 80, 160. If B filled in 1/16 of a tank in 3 hours, how much time will it take to fill the tank completely?
a) 9 B) 8 c) 7 d) 6 

3. There are two water tanks A and B, A is much smaller than B. While water fills at the rate of 1 liter every hour in A, it gets filled up like, 10, 20, 40,80, 160...in tank B. 1/8 th of the tank B is filled in 22 hours. What is the time to fill the tank fully?
a) 26 B) 25 c) 5 d) 27 

4. A tank is filled with water. In first hour 10 liters, second hours 20 liters, and third hour 40 liters and so on. If time taken to fill of the tank if 5 hours. What is the time taken to fill up the tank?
a) 5 B) 8 c) 7 d) 12.5 

5. If a tank A can be filled within 10 hours and tank B can be filled in 19 hours then, what is the time taken to fill up the tank completely?
a) 21 B) 38 c) 57 d) 76 
TCS Model 3:

1. 6 persons standing in queue with different age group, after two years their average age will be 43 and seventh person joined with them. Hence the current average age has become 45.Find the age of seventh person?
a) 43 b) 69 c) 52 d) 31 

Solution:
Total age of 6 persons is x hours,after two years total age of 6 persons is x+12
Average age of 6 persons is after two years is 43
So (x+12)/6=43,then solve x,
After 7th person is added then (x+7th person age)/7=45
So we will get 7th person age easily 

2. In a market 4 men are standing. The average age of the four before 4years is 45, after some days one man is added and his age is 49. What is the average age of all?
a) 43 b) 45 c) 47 d) 49 

3. In a shopping mall with a staff of 5 members the average age is 45 years. After 5 years a person joined them and the average age is again 45 years. What�s the age of 6th person? 
a) 25 b)20 c)45 d)30 

4. In a market 4 men are standing .The average age of the four before 2 years is 55, after some days one man is added and his age is 45. What is the average age of all?
a) 55 b) 54.5 c) 54.6 d) 54.7 

TCS Model 4: 
1. In the reading room of a library, there are 23 reading spots. Each reading spot consists of a round table with 9 chairs placed around it. There are some readers such that in each occupied
reading spot there are different numbers of readers. If in all there are 36 readers, how many reading spots do not have even a single reader?
a) 8 b) none c) 16 d) 15 
Solution: 23 reading spots, Each reading spot consists of 9 chairs placed around it so There are some readers such that in each occupied reading spot there are different numbers of
readers. For each table different no of persons are sat,so for first table 1 person is sit,2nd table 2 persons are sit 36 
readers means(1+2+3+4+5+6+7+8 so 8 tables are filled so 23-8=15 reading spots does not have single reader. 

2. In the reading room of a library, there are 10 tables, 4 chairs per table. In each table there are different numbers of people seated. How many tables will be left out without at least 1 person?
a) 8 b) 6 c) 2 d) 7 

3. In the reading room of a library, there are 10 tables, 4 chairs per table. In each table there are different numbers of people seated. How many ways they will sit in the library so that no chair would be blank?
a) 8 b) 6 c) 2 d) 7 

TCS Model 5:
1. A man jogs at 6 mph over a certain journey and walks over the same route at 4 mph. What is his average speed for the journey?
a) 2.4 mph b) 4.8 mph c) 4 mph d) 5 mph 
Solution: Average speed=(2*x*y)/(x+y) 

2. A man travels from A to B at 4 mph over a certain journey and returns over the same route to A, at 5 mph. What is his average speed for the journey?
a) 4.44 mph b) 4.8 mph c) 4.887 mph d)5 mph 

3. A person is rock climbing at an altitude of 800 m. He go up by 7 mph. and come down by 9 mph. what was his average speed?
a) 7.875 mph b) 7.125 mph c) 7mph d) 7.5 mph 

4. Find average speed if a man travels at speed of 24kmph up and 36kmph down at an altitude of 200m?
a) 28.8 mph b) 27.8 mph c) 27.5mph d) 30 mph 

5. Person travels to a hill, if he goes from A to B with speed of 4kmph and returns back to B with speed of 5kmph. What is his average speed of journey?
a) 4.5kmph b) 4.44kmph c) 9kmph d) 4.245kmph 

6. A man travels from A to B at 70 mph over a certain journey and returns over the same route to A, at 80 mph. What is his average speed for the journey?
a) 74.66 b)75 c)74.33 d)74.99 

7. Find average speed if a man travels at speed of 24kmph up and 36kmph down at an altitude of 200m.
a) 28.8 b)28 c)27 d)28.6 

TCS Model 6: 
1. Susan made a block with small cubes of 8 cubic cm volume to make a block ,3 small cubes long, 9 small cubes wide and 5 small cubes deep. She realizes that she has used more small cubes than she really needed. She realized that she could have glued a fewer number of cubes together to lock like a block with same dimensions, if it were made hollow. What is the minimum number of cubes that she needs to make the block?
a) 114 b) 135 c) 21 d) 71 

Solution: I do not know perfectly but I got some solutions from internet I do not know correctly whether it is tru e or not,((3*9*5))-((3-2)*(9-2)*(5-2)) so answer is 114. 

2. A boy wants to make cuboids of dimension 5m, 6m and 7m from small cubes of .03 m3. Later he realized he can make same cuboid by making it hollow. Then it takes some cubes less. What is the number of the cubes to be removed?
a) 2000 b) 5000 c) 3000 d) 7000 

3. Smita was making a cube with dimensions 5*5*5 using 1*1*1 cubes. What is the number of cubes needed to make a hollow cube looking of the same shape?
a) 98 b) 104 c) 100 d) 61 

4. Leena cut small cubes of 10 cm dimension each. She joined it to make a cuboid of length 100 cm, width 50 cm and depth 50 cm. How many more cubes does she need to make a perfect cube?
a) 500 b) 250 c) 750 d) 650 

5. Leena cut small cubes of 3 cubic cm each. She joined it to make a cuboid of length 10 cm, width 3 cm and depth 3 cm. How many more cubes does she need to make a perfect cube?
a) 910 b) 250 c) 750 d) 650 

6. A lady builds 9cm length, 10cm width,3cm height box using 1 cubic cm cubes. What is the minimum number of cubes required to build the box?
a) 730 b) 270 c) 720 d) 310 

TCS Model 8: 
1. (40*40*40 31*31*31)/(40*40+40*31+31*31)=?
a)8 b)9 c)71 d)51 

Solution:a3 -b3 =(a-b)*(a2+a*b+b2) so from this formula we will find (a-b) value 

2. (98*98*98 73*73*73)/( 98*98*98 73*73*73)=?
a).171 b).4 c).420 d).415 

3. (209*144)^2 + (209*209)+(209*144)+(144*144) = ?
a)905863729 b)905368729 c)905729368 d)65 

TCS Model 9: 
1. ((4x+3y)+(5x+9y))/(5x+5y) = ? as (x/2y) = 2
a)8 b)none c)16 d)15 
Solution: substitute x=4y in above we can find solution 

2. x/2y = 2a,then 2x/x-2ay=?
a)4 b)8 c)16 d)2 

3. 3X/5Y = 5Y/3X�..Find the value of X/Y
a) 3/5 b) 5/3 c) 2/5 d) 5/2 

4. What is the value of (3X+8Y)/(X-2Y), if X/2Y=2
a) 8 b) none c) 10 d) 13 

5. (4x+3y)+(5x+9y))/(5x+5y) = ? as (x/2y) = 2
a) 48/5 b) 46/5 c) 47/5 d) 49/5 

6. ((4x+2y)/(4x-2y)= ? as (x/2y) = 2
a) 8/7 b) 9/7 c) 11/7 d) 6/7 

TCS Model 10: 
1. A girl has to make pizza with different toppings. There are 8 different toppings. In how many ways can she make pizzas with 2 different toppings?
a) 16 b) 56 c) 112 d) 28 
Solution: 8c2 

2. A pizza shop made pizzas with many flavors. There are 10 different flavors, in that 7 flavors are taken to make pizza. In how many ways they can arrange?
a) 240 b) 120 c) 65 d) 210 

3. A pizza shop made pizzas with many flavours. There are 9 different flavors, in that 2 flavors are taken to make pizza. In how many ways they can arrange?
a) 16 b) 26 c) 36 d) 46 

TCS Model 11: 
1. 3, 22, 7, 45, 15, ?, 31
a) 91 b)151 c) 90 d) 5 

2. 8 6 17 14 35 31 75 _ 143? Ans :-66 

3. Inspired by Fibonacci series Sangeet decided to create his own series which is 1, 2, 3, 7, 7,22, 15, 67, 31, _, 63?
a) 202 b) 31 c) 76 d) 49 

4. 3, 12, 7, 26, 15, ?
a) 54 b) 27 c) 108 d) 31 

5. 1! + 2! + ��. + 50!=?
a)3.1035*10^64 b)2.1021*10^65 c)3.1035*10^63 d)3.1035*10^62 

6. 1, 2, 3, 6, 7, 14, _, 32? 

7. 5, 9, 12, 18, 26, 36, 47, 72, _?
a) 75 b) 135 c) 100 d) 55 

8. 3, 15, x, 51, 53,159,161
a) 17 b) 34 c) 54 d) 112 

TCS Model 12: 
1. Simple question but big one on average age.sth like a, b, c weighted separately 1st a, b, c ,then a& b, then b & c ,then c & a at last abc, the last weight was 167,then what will be the average weight of the 7 reading?
a) 95 b) 95.428 c) 95.45 d) 94 
Solution: Last weight abc is 167i.e three persons weight is 167 .in first 6 combinations a,b,c,ab,bc,ac i.e a checked weight for 3 times totally like that band c also so total weight in all 7 combinations is (4*167) 
Average is (668/7)=95.42 
TCS Model 13: 
1. A toy train produces 10 different sounds when it moves around a circular toy track of radius 5 m at 10 m per min. However, the toy train is defective and it now produces only 2 different tunes at random. What are the odds that the train produces for consecutive music tones of the same type?
a) 1 in 16 B) 1 in 4 c) 1 in 8 d) 1 in 32 


Solution: Initially it produces 10 sounds and the defect came and now it produces only 2 different sounds and consecutively so there are totally 2 sounds and we have to select on sound and the probability is and it produces the same sound consecutively for 2 times so the probability becomes �*1/2 ie � 

2. A car manufacturer produces only red and blue TCS Models which come out of the final testing area at random. What are the odds that five consecutive cars of same color will come throughthe test area at any one time?
a) 1 in 16 b) 1 in 125 c) 1 in 32 d) 1 in 25 

TCS Model 15: 
1. A triangle is made from a rope. The sides of the triangle are 25 cm, 11 cm and 31 cm. What will be the area of the square made from the same rope?
a) 280.5625 b) 240.5625 c) 280.125 d) 240 

Solution: Add all sides 25+11+31 to get rope length rope length =67,rope is made in to as square. So side of square is 67/4=16.75 and so area is 16.75*16.75=280.5625 

2. A triangle is made from a rope. The sides of the triangle are 21 cm, 24 cm and 28 cm. What will be the area of the square made from the same rope?
a) 280.5625 b) 333.0625 c) 333.0125 d) 400 

TCS Model 16: 
1. What is the distance between the z-intercept from the x-intercept in the equation
ax+by+cz+d=0
Solution: intercept form equation 

2. What is the distance of the z-intercept from the x-intercept in the equation ax+by+cz=d (I do not remember the values of a, b, c, d). 

TCS Model 17: 
1. A scientist was researching on animal behaviour in his lab. He was very interested in analysing the behaviour of bear. For some reason he travelled 1mile in north direction & reached at North Pole. There he saw a bear. He then followed the bear around 1 hr with a speed of 2km/hr in east direction. After that he travelled in south direction & reached at his lab in2 hrs. Then what is the color of the bear?
a) White b) Black c) Gray d) Brown 
Solution is: White. above all the matter is nonsense 

TCS Model 18: 

1. Out of 7 children the youngest is boy then find the probability that all the remaining children are boys
a) 1/64 b) 1/32 c) 1/128 d) 1/256 

TCS Model 19: 
1. Usha bought a linen cloth and rope to build a tent. If the rope is 153 m long and it is to be cut into pieces of 1m length, then how many cuts are to be made to cut the ropes into 153 pieces?
a) 153 b) 152 c) 154 d) 155 
Solution: To make it 153 pieces we have to cut 152 times so obviously after last cut we got 153rd piece 

2. A person has to make 146 pieces of a long bar. He takes 4 seconds to cut a piece. What is the total time taken by him in seconds to make 146 pieces?
a) 584 b) 580 c) 730 d) 725 
Solution: 146 pieces means 145 cuts so for each cut it takes 4 seconds means total time 145*4=580 

3. A person has to make 141 pieces of a long bar. He takes 2 seconds to cut a piece. What is the total time taken by him in seconds to make 141 pieces?
a) 560 b) 280 c) 112 d) 324 

TCS Model 20: 

1. Spores of a fungus, called late blight, grow and spread infection rapidly. These pathogens were responsible for the Irish potato famine of the mid-19th century. These seem to have attacked the tomato crops in England this year. The tomato crops have reduced and the price of the crop has risen up. The price has already gone up to $45 a box from $27 a box a month ago. How much more would a vegetable vendor need to pay to buy 27 boxes this month over what he would have paid last month?
a) $27 b) $18 c) $45 d) $486 
Solution: See last 3 lines only answer is 45-27=18 

TCS Model 21: 
1. A Person buys a horse for 15 ponds, after one year he sells it for 20 pounds. After one year, again he buys the same horse at 30 pounds and sells it for 40 pounds. What is the profit for that person? 
Solution: here we cannot consider depreciation or decay of item accto answer so go acc to 
answer 
Totally 5+10=15$profit

TCS Model 22: 
1. John buys a cycle for 31 dollars and given a cheque of amount 35 dollars. Shop Keeper exchanged the cheque with his neighbour and gave change to John. After 2 days, it is known that cheque is bounced. Shop keeper paid the amount to his neighbour. The cost price of cycle is 19 dollars. What is the profit/loss for shop keeper? 
a) loss 23 b) gain 23 c) gain 54 d) Loss 54 
Solution: Loss= Change of money given to john(4$)+actual cycle cost 19$=23$ loss 

TCS Model 23: 
1. A lady has fine gloves and hats in her closet- 18 blue, 32 red, and 25 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove.How many gloves must she take out to make sure she has a pair of each color?
a) 50 b) 8 c) 60 d) 42 

2. A lady has fine gloves and hats in her closet- 14 blue, 20 red, and 18 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove. How many gloves must she take out to make sure she has a pair of each color? 

3. A lady has fine gloves and hats in her closet- 13 blue, 27 red, and 40 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove. How many gloves must she take out to make sure she has a pair of each color? 

4. A lady has fine gloves and hats in her closet- 25 blue, 7 red, and 9 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove.How many gloves must she take out to make sure she has a pair of each color? 

5. A lady has fine gloves and hats in her closet- 26 blue, 30 red, and 56 yellow. The lights are out and it is totally dark. In spite of the darkness, she can make out the difference between a hat and a glove. She takes out an item out of the closet only if she is sure that if it is a glove. How many gloves must she take out to make sure she has a pair of each color? 

TCS Model 24: 
1. Sangakara and Ponting select batting by using a dice, but dice is biased. So to resolve,Ponting takes out a coin. What is the probability that coin shows correct option?
a)1/2 b)1/6 c)1/12 d)6/10 
Solution is. 

2. There is a die with 10 faces. It is not known that fair or not. 2 captains want to toss die forbatting selection. What is the possible solution among the following?
a) If no. is odd it is head, if no. is even it is tail
b) If no. is odd it is tail, if no. is even it is head
c) Toss a die until all the 10 digits appear on top face. And if first no. in the sequence is odd then consider it as tail. If it is even consider it as head. 

TCS Model 25:
1. In a family there are some boys and girls. All boys told that they are having equal no ofbrothers and sisters and girls told that they are having twice the no. of brothers than sisters.How many boys and girls present in a family?
a) 4 boys and 3 girls b) 3 boys and 4 girls c) 2 boys and 5 girls d) 5 boys and 2 girls 

TCS Model 26: 
1. 10 men and 10 women are there, they dance with each other, is there possibility that 2 men are dancing with same women and vice versa?
a) 22 b) 20 c) 10 d) none 

2. There are 100 men and 100 women on the dance floor. They want to dance with each other. Then which of the following statements is always true: 
a) There are 2 men who danced with equal no. of women’s
b) There are 2 women who danced with equal no. of men
a) both a and b b)only a c)only b d)none 

TCS Model 27: 
1. Middle- earth is a fictional land inhabited by hobbits, elves, dwarves and men. The hobbits and elves are peaceful creatures that prefer slow, silent lives and appreciate nature and art. The dwarves and the men engage in physical games. The game is as follows. A tournament is one where out of the two teams that play a match, the one that loses get eliminated. The matches are played in different rounds, where in every round; half of the teams get eliminated from the tournament. If there are 8 rounds played in knock out tournament, how many matches were played?
a) 257 b) 256 c) 72 d) 255
Solution: Do not know perfect logic 28 

2. A game is played between 2 players and one player is declared as winner. All the winners from first round are played in second round. All the winners from second round are played in third round and so on. If 8 rounds are played to declare only one player as winner, how many players are played in first round?
a) 256 b) 512 c) 64 d) 128 

TCS Model 28: 
1. Metal strip of width �x� cm. 2 metal strips are placed one over the other, then the combine length of 2 strips is �y�. If �z� strips are placed in that manner. What is the final width of that arrangement? 

2. A, B, C, D, E are there among A, B, C are boys and D, E are girls D is to the left of A and no girl sits at the middle and at the extemes. Then what is the order of their sittings. 

TCS Model 29: 
1. There is 7 friends (A1, A2, A3....A7).If A1 have to have shake with all without repeat. How many handshakes possible?
a) 6 b) 21 c) 28 d) 7 
Solution: For handshakes type question i am confirming you that if the there are n membersare there Handshakes are given in linear manner =n-1(last person cannot give hand shake to first
person) Handshakes are given in cyclic manner =n(last person can give hand shake to first person) But i do not know perfectly for repetition it is nc2 

2. 49 members attended the party. In that 22 are males, 17 are females. The shake hands between males, females, male and female. Total 12 people given shake hands. How many such kinds of such shake hands are possible?
a) 122 b) 66 c) 48 d)1 28

Thursday, 25 July 2013

Accenture Programs-Questions Previously asked questions


Rendered Image

Accenture Programs-Questions Previously asked questions

Factorial of number?
Sorting an array??
Fibonacci series?
Perfect number?
Armstrong number?
Reverse of string(with and without string reverse)
Can you write a c program for 2x3 and 3x1 matrix multiplication?

Accenture Technical Questions

Difference between Arrays and Linked List?
What are pointers in c?
What is data warehousing?
What is Recursion Function?
What is TDM?
What are the layers of OSI Model?
Difference between TCP and UDP?
What is Function Overloading?
What is the difference between C and Java?
What is the difference between array and pointer?
What is normalisation?and their types?
What is the difference between Char and Varchar in DBMS?
What is the difference between C and CPP?
Why C is procedural?
What are the phases of a compiler?
Define Routing Algorithm?
Define map and hash functions?
What is circular linked list?
What are the types of data models?

Accenture GD Topics
GD Topics
Duration
15 to 20 minutes
GD Panel
10 to 12 Members

RECENT GD TOPICS

Status of women in india?
How Indians are harassed in Australia and what should we do to help them?
Innovation in Software?
Dress code is Necessary for College Students are not?
Ragging should be legalised?
Effect of cinema on Youth?
India china economy?
Reservation System in India?
Politics in India between regional and national parties?
Impact of Global Warming?
Impact of IT on India?
Why India is Lagging in Olympics?
Should Hockey still be the national game of India?
Impact of Televisions on Humans?
should actors join Politics?

Accenture HR Interview

Project
Explain Your Current Project?

Accenture -RECENT HR INTERVIEW QUESTIONS

Tell me about yourself?
Why Accenture?
What are your short term and long term goals?
What do you know about Accenture?
Can you go anywhere for working in Accenture?
Are you ready to sign a service Agreement?
Tell me top 3 Indian IT Companies?
Which is your favorite subject?
What are your Achievements?
What are your Hobbies?
Do you have any question for me?

Accenture aptitude questions, Accenture free on line mock test questions with answers,

1. Some guy holding a glass of wine in his hand looking around in the room says, "This is same as it was four years ago, how old are your two kids now?" Other guy says "Three now, Pam had one more in the meanwhile." Pam says, "If you multiply their ages, answer is 96 and if you add the ages of first two kids, addition is same as our house number." The first guy says, "You are very smart but that doesn't tell me their ages." Pam says, "It's very simple, just think." What are the ages of three kids?

Ans: 8, 6, 2

2. My rack contains 8 Red colour ties, 13 violate colour ties,10 Blue colour ties, 5 Pink colour ties, 4 green colour ties. If electricity gone and i want at least two ties of same colour then how many ties i should take out from my rack?

Ans : 6 ties.

3. Two trains leaving from two station 50 miles away from each other with costant speed of 60 miles per hour, approaches towards each other on diffrent tracks. if lenght of each train is 1/6 mile. when they meet How much time they need to pass each other totally?

ANS : 10 sec. ( not sure)

4. A man walks east and turns right and then from there to his left and then 45degrees to his right. In which direction did he go

Ans. North west

5. A man shows his friend a woman sitting in a park and says that she the daughter of my grandmother's only son. What is the relation between the two

Ans. Daughter

6. water is continuously poured from a reservoir to a locality at the steady rate of 10,000 liters per hour. When delivery exceeds demand the excess water is stored in a tank. If the demand for 8 consecutive three-hour periods is 10000,10000,45000,25000,40000,15000,60000 and 35000 liters respectively, what will be the minimum capacity required of the water tank (in 1000 litres) to meet the demand?

Ans:40

7. If 5 tomatoes are worth 8 oranges,5 oranges are worth 4 apples, 7 apples are worth 3 pineapples and 7 pineapples cost rs.203,then he approx price of each tomato is

Ans.16

8.The radius of the circle is reduced from 5cm to 4cm then the % change of area .

Ans: 36%

9.Two workers can type two pages in two minuets then how many persons can type 18 pages in 6 minuets

Ans: 6

10. X is min of { n+5,6-n} then what is the min of X if,0 <1?

Ans 5.5

Accenture programming Questions

1. What is the output of the program
void main()
{
char s[]="oracle is the best";
char t[40];
char *ss,*tt;
while(*tt++=*ss++);
printf("%s",t);
getch();
}
// A. oracle is the best
// B. Core dump
// c. Error Message
// D. Goes into infinite loop
Ans: B. core dump (Garbage value)

2. .//What is the output of the program
void main()
{
fork();
printf(" Hello World");
getch();
}
// A. Hello World
// B. Hello World Hello World
// c. Error Message
// D. None of these
Ans: B

3. What is the output of the program
void main()
{
int i,j,k;
i=2;
j=4;
k=i++>j&2;
printf("%d\n",k);
if(++k && ++i<--j|| i++)
{
j=++k;
}
printf(" %d %d %d",i,-j--,k);
getch();
}
// A. 4,-3,2
// B. 5,-3,2
// c. 4,-2,2
// D. 5,-2,2
Ans: D

4. public void static main(String []args)
{
String s1=new String("test");
String s2=new String("test");
if(s1==s2)
System.out.println("Both are equal");
Boolean b1=new Boolean("true");
Boolean b2=new Boolean("false");
if(b1.equals(b2))
System.out.println("some message");
}
output=?

9.
x=7;
y=0;
if(x=y)y=7;
else
y=5;
what is the value of y

5.The ratio between the radius and height of a cone is 3:4. What is the curved surface area of the cone?
1) 15p m2
2) 12p m2
3) 9p m2
4) Data inadequate
5) None of these

6. A man stands on the top of a pole and makes an angle of 60° on the surface of a ground. He slides 20 m down and makes an angle of 30°at the same point. If he takes 10 seconds to reach the ground from here, find his speed.
1) 6 km/hr
2) 5 km/hr
3) 10 km/hr
4) 8 km/hr
5) 10.80 km/hr

7.The compound interest for first and second years is 200 and 220 on a certain amount. Find the sum.

8. Marked price of a commodity is 35% above the cost price. If he gives a discount of 15%, how much he gains on the deal.

9. 5 mangoes + 4 oranges = 7 mangoes + 1 orange. Find the ratio of mango to orange.

10. Length of a rectangle is increased by 50% and breadth is decreased by 25% what is the difference in the area

11. Mr X position in a class is 13th from first and 17th from last, and 8th from the first and 13th from last in passed candidates list, then how many candidates failed in the exam

12. Two successive discounts of 20% and 15% is equal to a net discount of .....

13. A two digit number is 4 times to its sum of digits , when 9 is added to the number, the digits will get reversed. Then what is that number?

Ans: 12

14. When do you say that a digraph is a cyclic
A)if and only if its first search does not have back arcs
B)a digraph is acyclic if and only if its first search does not have back vertices
C)if and only if its first search does not have same dfnumber
D)None of these

15.A function ‘q’ that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as:
A)int (*q(char*)) []
B)int *q(char*) []
C)int(*q)(char*) []
D)None of the Above


16.study the code:
#include
void main()
{
const int a=100;
int *p;
p=&a;
(*p)++;
printf("a=%dn(*p)=%dn",a,*p);
}
What is printed?



17. In how many ways can a lock be opened if that lock has three digit number lock if
i) the last digit is 9
ii) and sum of the first two digits is less than or equal to the last digit. numbers are from 0-9

18. A person sold an item at a profit of 12% .If he sold it at a loss of 12% then he would get Rs.6/- less. What is the cost price?

19. (1 ½ /((3/4-2/5 )/(2/3+4/5))) * ((2 ¾/((4/3-2/5 )/(5/3+6/5))) (Numbers different)

20. Avg age of X number of adults in a class is 30yrs. If 12 new adults with avg age of 32 joined with them then the avg age increases by one. Find X?
Accenture -2010 Questions
1. What is the value of *second_ptr
int *first_ptr;
int *second_ptr;

*second_ptr = 30;

ptr value = 1;

first_ptr = &value

second_ptr = first_ptr;

(A) 30
(B) 1
(C) first_ptr
(D) None of the above

2. What is the output of the program

void main()

{

int i,j,k;

i=2;

j=4;

k=i++>j&2;

printf("%d\n",k);

if(++k && ++i<--j|| i++)

{

j=++k;

}

printf(" %d %d %d",i,-j--,k);

getch();

}

A. 4,-3,2

B. 5,-3,2

c. 4,-2,2

D. 5,-2,2

Ans: D


3. Output of the following program is
main()
{
int i=0;
for(i=0;i<20;i++)
{
switch(i){
case 0:
i+=5;
case 1:
i+=2;
case 5:
i+=5;
default:
i+=4;
break;
}
}
}
(

4. Find the approximate value of the following equation. 6.23% of 258.43 - ? + 3.11% of 127 = 13.87
1) 2
2) 4
3) 8
4) 6
5) 10

5. A train overtakes 2 persons walking at 3 km/hr and 5 km/hr respectively in the same direction and completely passes them in 8 seconds and 10 seconds respectively. Find the speed of the train.
1) 15 km/hr
2) 13 km/hr
3) 10 km/hr
4) 10 km/hr
5) None of these

6. The ratio between the radius and height of a cone is 3:4. What is the curved surface area of the cone?
1) 15p m2
2) 12p m2
3) 9p m2
4) Data inadequate
5) None of these

7. In a business P and Q invested amounts in the ratio 3:4, whereas the ratio between amounts invested by P and R was 6:7. If Rs 106501.50 was their profit, how much amount did Q receive?
1) Rs 40572
2) Rs 30429
3) Rs 35500.50
4) Rs 34629
5) None of these


8. A function ‘q’ that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as:
A)int (*q(char*)) []
B)int *q(char*) []
C)int(*q)(char*) []
D)None of the Above

9. Identify the correct argument for the function call fflush() in ANSI C:
A)stdout
B)stdin
C)stderr
D)All the above

10. Which of the Following will define a type NODE that is a node in a Linked list?
A)struct node {NODE*next;int x;};type def struct node NODE;
B)typedef struct NODE {struct NODE *next;int x;};
C)typedef struct NODE {NODE *next;int x;};
D)typedef struct {NODE *next;int x;}NODE;

11.Which of these statements are false w.r.t File Functions?

i)fputs() ii)fdopen() iii)fgetpos() iv)ferror()



10.Study the code:
void show()
main()
{
show();
}
void show (char *s)
{
printf("%sn",s);
}

What will happen if it is compiled & run on an ANSI C Compiler?

A)It will compile & nothing will be printed when it is executed
B)it will compile but not link
C)the compiler will generate an error
D)the compiler will generate a warning

12. After 10 years A will be twice the age of B before 10 years.and now if the difference is 9 years between them then what is the age of B after 10 years

Ans 49

13. Races and games ---- 2 questions from this chapter like (A beats B by 10 meters and B beats C by 15 metres the A beats C by )

14. In the year 1990 there are 5000 men 3000 women 2000 boys .in 1994 men are increased by 20% women are increased by ratio of boys and women (this type of question but some what difficult I mean it takes too much time to solve)

15. The equivalent compound ratio of 5:6::7:10::6:5 ( question of this type this is not exact question).

16. Work can be done by 8 men and 10 women in 25 days, the same work can be done by 10 children and 5 women . in how many days 2 children and 3 men (similar to this)

17. One Cannot Take the address of a Bit Field

b.bit fields cannot be arrayed
c.Bit-Fields are machine Dependant
d.Bit-fields cannot be declared as static
Which of the Following Statements are true w.r.t Bit-Fields


18. What is the function of ceil(X) defined in math.h do?

A)It returns the value rounded down to the next lower integer
B)it returns the value rounded up to the next higher integer
C)the Next Higher Value
D)the next lower value


19. A shopkeeper labels the price of article 15% above the cost price. If he allow Rs 51.20 discount on an article of Rs 1024, find his profit percent.

1) 10%
2) 8%
3) 12%
4) 9%
5) 9.25%

20.Which of the following numbers are completely divisible by 11?

A. 3245682
B. 283712
C. 438416
D. 36894

1) Only A
2) Only B
3) Only C
4) Only D
5) All are divisible
Accenture 2011 question papers

1. #include
void main()
{
char s1[]="abcd";
char s2[10];
char s3[]="efgh";
int i;
clrscr();
i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd"));
printf("%d",i);
}

What will be the output?

2. Look at the Code:
main()
{
int a[]={1,2,3},i;
for(i=0;i<3;i++)
{
printf("%d",*a);
a++;
}
}

3. Which Statement is/are True w.r.t the above code?
I.Executes Successfully & Prints the contents of the array
II.Gives the Error:Lvalue Required
III.The address of the array should not be changed
IV.None of the Above.

A)Only I B)Only II C)II & III D)IV

4. study the code:
#include
void main()
{
const int a=100;
int *p;
p=&a;
(*p)++;
printf("a=%dn(*p)=%dn",a,*p);
}
What is printed?



5. Which of the following are valid “include” formats?
A)#include and #include[file.h]
B)#include (file.h) and #include
C)#include [file.h] and #include “file.h”
D)#include and #include “file.h”

6. Work can be done by 8 men and 10 women in 25 days, the same work can be done by 10 children and 5 women . in how many days 2 children and 3 men (similar to this)

7. One man or two women or three boys can do a work in 44 days then one man, one women and one boy together can fininsh the same work in ---- dyas

8. (998-1) (998-2) (998-3)????.. (998-n)=------- when n>1000 ans is zero

9.Study the Following Points:
a.One Cannot Take the address of a Bit Field
b.bit fields cannot be arrayed
c.Bit-Fields are machine Dependant
d.Bit-fields cannot be declared as static
Which of the Following Statements are true w.r.t Bit-Fields


10. What is the function of ceil(X) defined in math.h do?
A)It returns the value rounded down to the next lower integer
B)it returns the value rounded up to the next higher integer
C)the Next Higher Value
D)the next lower value

11.The ratio between the radius and height of a cone is 3:4. What is the curved surface area of the cone?

1) 15p m2
2) 12p m2
3) 9p m2
4) Data inadequate
5) None of these

12. A man stands on the top of a pole and makes an angle of 60° on the surface of a ground. He slides 20 m down and makes an angle of 30°at the same point. If he takes 10 seconds to reach the ground from here, find his speed.

1) 6 km/hr
2) 5 km/hr
3) 10 km/hr
4) 8 km/hr
5) 10.80 km/hr

13. Which of the following values of 'n' satisfies the in-equality n2 - 24n + 143 < 0?

1) n < 11
2) n > 13
3) 11 < n < 13
4) 11 > n > 13
5) None of these

14. If 2x+y = 11, 2y+z = 12 and z+2x = 8, find the value of 2x + 3y +4z.

1) 29
2) 33
3) 25
4) 39
5) None of these

15. What is not true about the following statements about java.
a) it is compiled using javac compiler
b) the compiled files have .class extension.
c) such files cannot be transfered from one comp to another.
d) they use the java interpreter

Ans: c

16. Which of the Following is not defined in string.h?

A)strspn()
B)strerror()
C)memchr()
D)strod()

17.Identify the correct argument for the function call fflush() in ANSI C:

A)stdout
B)stdin
C)stderr
D)All the above

18. Which of the Following will define a type NODE that is a node in a Linked list?
A)struct node {NODE*next;int x;};type def struct node NODE;
B)typedef struct NODE {struct NODE *next;int x;};
C)typedef struct NODE {NODE *next;int x;};
D)typedef struct {NODE *next;int x;}NODE;


19. How many columns are retrived from this query:
SELECT address1 || ',' ||address2 ||','
||address2 "Address" FROM =
employee;

A. 3
B. 2
C. 1
D. 0

20. What is the is the result of the fallowing Code
Piece=20
Insert into table A value(a1):
CREATE TABLE B AS SELECT * FROM A;
ROLLBACK ;

A. Table B gets created with the row inserted in the first statement.
B. Table B is not created
C. Table B gets created , but no row gets inserted into Table A
D. Rollback throws up an exception .

Accenture Latest Placement paper 2012-2013 Technical HR and Group discussion Topics

Rendered Image

Accenture Latest Placement paper 2012-2013 Technical HR and Group discussion Topics




Which is the parameter that is added to every non-static member function when it is called?

Answer: 'this' pointer
What is a binary semaphore? What is its use?

Answer:

A binary semaphore is one, which takes only 0 and 1 as values. They are used to implement mutual exclusion and synchronize concurrent processes.

What is thrashing?

Answer:

It is a phenomenon in virtual memory schemes when the processor spends most of its time swapping pages, rather than executing instructions. This is due to an inordinate number of page faults.

What are turnaround time and response time?

Answer:

Turnaround time is the interval between the submission of a job and its completion. Response time is the interval between submission of a request, and the first response to that request.

What is data structure?

Answer: A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.

List out the areas in which data structures are applied extensively?

Answer: The name of areas are:

Compiler Design,
Operating System,
Database Management System,
Statistical analysis package,
Numerical Analysis,
Graphics,
Artificial Intelligence,
Simulation

What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model.

Answer: The major data structures used are as follows:

RDBMS - Array (i.e. Array of structures)
Network data model - Graph
Hierarchical data model - Trees
What is the data structures used to perform recursion?

Answer: Stack. Because of its LIFO (Last In First Out) property it remembers its 'caller' so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls.

Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.
Predict the output or error(s) for the following:

void main()
{
int const * p=5;
printf("%d",++(*p));
}

Answer:

Compiler error: Cannot modify a constant value.

Explanation: p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".

main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}

Answer:

mmmm
aaaa
nnnn

Explanation:s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].

main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}

Answer:

I hate U

Explanation: For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.

Rule of Thumb:

Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ).
List out few of the Application of tree data-structure?

Answer: The list is as follows:

The manipulation of Arithmetic expression,
Symbol Table construction,
Syntax analysis.
List out few of the applications that make use of Multi linked Structures?

Answer: The applications are listed below:

Sparse matrix,
Index generation.

In tree construction which is the suitable efficient data structure?

Answer: Linked list is the efficient data structure.

What is the type of the algorithm used in solving the 8 Queens problem?

Answer: Backtracking
In RDBMS, what is the efficient data structure used in the internal storage representation?

Answer: B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes.

Whether Linked List is linear or Non-linear data structure?

Answer: According to Access strategies Linked list is a linear one.
According to Storage Linked List is a Non-linear one.


Wednesday, 24 July 2013

Trick To Find User Surname Of Any Reliance Mobile Number

Trick To Find User Surname Of Any Reliance Mobile Number

reliance number
reliance number
While searching on web for finding details of user of particular mobile number, I came across a website that can help you to get little information about that user. In this tutorial i will teach you to find surname of Reliance mobile number user in few simple steps. Basically this website is for recharge but it helps you to get information about user of that mobile number. So lets dive into it.


   1. Go to this  Website
   2. Enter Mobile Number in Reliance Subscriber Number.
   3. Email address is optional so you don't need to enter.
   4. Done!!!

Top 5 Cool Notepad Virus Tricks

Top 5 Cool Notepad Virus Tricks


notepad tricks
I had previously share some Interesting computer tricks as well as cool Batch file programs. In this post i will share with you guys some of the cool notepad tricks.As name suggest you don't require any program other then notepad. So lets get started.

1. World Trade Center Attack Trick

world trade center trick
world trade center trick


The flight number of the plane that had hit World Trade Center on  (9/11) was Q33NY. Now we call this trick or a coincidence or something else but whatever it is you will be definately amazed by the this trick.

    1. Open Notepad and Type “Q33N” (without quotes) in capital letters.
    2. Increase the font size to 72.
    3. Change the Font to Wingdings.


2. Matrix Effect Trick

matrix effect trick

matrix effect trick
In this trick i will show you to make a batch file in notepad which will act as matrix effect that you might have seen in movies.Matrix effect is basically number flashes in green color.

    1. Open Noteapad and copy below code into it.

@echo off
color 02
:start
echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random%
goto start

    2. Now save this file as Matrix.bat (name can be anything but .bat is must)
    3. Open your saved file and you will have matrix effect on your screen.



3. Creating Virus That Format C Drive



In this trick we will be creating virus in notepad using batch file programming. This virus is really simple to create yet very dangerous. opening this file we delete or format C drive of your computer.

    1. Open Notepad and copy below code into it.

@Echo off
Del C:\ *.* |y
 
    2. Then Save this file as virus.bat
    3. Now, running this file format C Drive.
Learn To Make Dangerous Virus In Minute
4. Making Personal Diary Using Notepad

notepad tricks

notepad tricks
Here you will learn to use notepad as Digital diary or a log book to keep record of your daily work instead of using pen and paper.

    1. Open Notepad and Type .LOG (in capital Letters and press enter
    2. Save the program with any name and close it.
    3. Open the file again. Now you can see current date and time, This will happen every time you reopen notepad

5. Dancing Keyboard Led

keyboard dancing led

keyboard dancing led

In this part i will show you to make interesting file using notepad which will make keyboard led to dance. basically we will be creating a visual basic script.

    1. Open Notepad and copy below codes into it.

Set wshShell =wscript.CreateObject("WScript.Shell")
do
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wshshell.sendkeys "{NUMLOCK}"
wshshell.sendkeys "{SCROLLLOCK}"
loop
    2. Then save this file as dance.vbs (name can be anything but .vbs is must)
    3. Open your save file and see your keyboard led blinking like disco lights.

Finding Ip Address Of A Website Using Command Prompt Or CMD

Finding Ip Address Of A Website Using Command Prompt Or CMD



In this tutorial i will teach you to find Ip Address of any website using Command Prompt or in short CMD. Using IP Address you can find location of the website server and do more stuff. I will demostrate this tutorial with Google but you can use this method to find IP Address of any website like twitter, facebook etc. So lets get started.
How to find IP ?

1. Go to Start > Type CMD and press Enter.

2. Now write Ping followed by website URL whose IP you want to find.
finding ip adddress of website

finding ip adddress of website

3. It will take less then a second and come up with the results as shown below.
finding ip adddress of website

finding ip adddress of website

In  my next post i will show you another easy way to find website IP Address and teach you to use this IP to find its location.

How to Hack Windows Password Without Any Software





Lost your windows password or want to hack your friends computer or want to hack your school computer ? then here’s  a hack to change your victims account passwor Without using any software 


There are many ways to hack a windows password but in this this tutorial I will explain How to Hack Windows Password Without Any Software follow the simple steps to hack a windows account

1. When you start your computer press f8 and select Safe mode as shown in the picture  and press Enter


2. Once you enter  the main menu you will see two accounts one is the administrator account and other is your victims account login in the administrator account

3. Now go to Start and open  control panel 

4. Now select User Accounts



5. Now select your victims account



6. Now select Remove The Password 

7. Now Restart  the computer and login the victims account without any password And do what ever you want  ( you can create your own password for the account )


Note :- This hack wont work if the admin account is either blocked or password Protected ,


Tuesday, 16 July 2013

bricks game source code c




bricks game source code c:



# include "process.h"
# include "dos.h"
# include "stdlib.h"
# include "graphics.h"
# include "stdio.h"
#include<conio.h>
#include<ctype.h>
# define NULL 0
# define YES 1
# define NO 0

int maxx, maxy, midx, midy ;
int bri[5][20] ;

/* plays different types of music */
music ( int type )
{
/* natural frequencies of 7 notes */
float octave[7] = { 130.81, 146.83, 164.81, 174.61, 196, 220, 246.94 } ;
int n, i ;

switch ( type )
{
case 1 :
for ( i = 0 ; i < 7 ; i++ )
{
sound ( octave[i] * 8 ) ;
delay ( 30 ) ;
}
nosound() ;
break ;

case 2 :
for ( i = 0 ; i < 15 ; i++ )
{
n = random ( 7 ) ;
sound ( octave[n] * 4 ) ;
delay ( 100 ) ;
}
nosound() ;
break ;

case 3 :
while ( !kbhit() )
{
n = random ( 7 ) ;
sound ( octave[n] * 4 ) ;
delay ( 100 ) ;
}
nosound() ;

/* flush the keyboard buffer */
if ( getch() == 0 )
getch() ;

break ;

case 4 :
for ( i = 4 ; i >= 0 ; i-- )
{
sound ( octave[i] * 4 ) ;
delay ( 15 ) ;
}
nosound() ;
break ;

case 5 :
sound ( octave[6] * 2 ) ;
delay ( 50 ) ;
nosound() ;
}
}



/* creates opening screen */
mainscreen()
{
/* array showing the positions where a brick is needed to form the figure BRICKS */
int ff[12][40] = {
1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,0,1,1,1,0,
1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,
1,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,
1,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,
1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,
1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,
1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,
1,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,
1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,
1,1,1,1,0,0,0,1,0,0,0,0,1,0,1,1,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,1,1,1,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
} ;
int i, j, lx = 0, ly = 0, ch ;

/* draw boundary */
rectangle ( 0, 0, maxx, maxy ) ;

/* form the word BRICKS */
for ( i = 0 ; i < 12 ; i++ )
{
for ( j = 0 ; j < 40 ; j++ )
{
if ( ff[i][j] )
rectangle ( lx, ly, lx + 15, ly + 9 ) ;
lx = lx + 16 ;
}
lx = 0 ;
ly = ly + 10 ;
}

/* draw pattern at the bottom of the screen */
line ( 0, maxy - 12, maxx, maxy - 12 ) ;
setfillstyle ( XHATCH_FILL, WHITE ) ;
floodfill ( 2, maxy - 2, WHITE ) ;

/* draw the paddle and the ball */
setfillstyle ( SOLID_FILL, WHITE ) ;
rectangle ( midx - 25, maxy - 7 - 12, midx + 25, maxy - 12 ) ;
floodfill ( midx, maxy - 1 - 12, 1 ) ;
circle ( midx, maxy - 13 - 12, 12 ) ;
floodfill ( midx, maxy - 10 - 12, 1 ) ;

music ( 3 ) ;  /* play music */

/* display menu */
while ( 1 )
{
/* clear the region below the word BRICKS */
setviewport ( 1, 125 - 12, maxx - 1, maxy - 1, 1 ) ;
clearviewport() ;

setviewport ( 0, 0, maxx, maxy, 1 ) ;
outtextxy ( 20, 135, "Select any of the following:" ) ;
outtextxy ( 20, 155, "Play ( P )" ) ;
outtextxy ( 20, 165, "Instructions ( I )" ) ;
outtextxy ( 20, 175, "Exit ( E )" ) ;

ch = 0 ;

/* continue till the correct choice is made */
while ( ! ( ch == 'E' || ch == 'I' || ch == 'P' ) )
{
fflush ( stdin ) ;

/* if a special key is hit, flush the keyboard buffer */
if ( ( ch = getch() ) == 0 )
getch() ;
else
ch = toupper ( ch ) ;
}

if ( ch == 'P' )
break ;

switch ( ch )
{
case 'I' :
setviewport ( 1, 125 - 12, maxx - 1, maxy - 1, 1 ) ;
clearviewport() ;

setviewport ( 0, 0, maxx, maxy, 1 ) ;
settextstyle ( DEFAULT_FONT, HORIZ_DIR, 1 ) ;
outtextxy ( 20, 125, "         Instructions        " ) ;
settextstyle ( DEFAULT_FONT, HORIZ_DIR, 0 ) ;
outtextxy ( 20, 140, "Use left and right arrow keys to move paddle." ) ;
outtextxy ( 20, 150, "If you don't collect the ball on the paddle, you lose the ball." ) ;
outtextxy ( 20, 160, "On loosing a ball you loose 20 points." ) ;
outtextxy ( 20, 170, "On taking a brick you gain 5 points." ) ;
outtextxy ( 20, 185, "Press any key..." ) ;
fflush ( stdin ) ;
if ( getch() == 0 )
getch() ;
break ;

case 'E' :
closegraph() ;
restorecrtmode() ;
exit ( 0 ) ;
}
}

setviewport ( 1, 125 - 12, maxx - 1, maxy - 1, 1 ) ;
clearviewport() ;

/* prompt the user for the level desired */
setviewport ( 0, 0, maxx, maxy, 1 ) ;
outtextxy ( 20, 135, "Select any of the following levels:" ) ;
outtextxy ( 20, 155, "Novice ( N )" ) ;
outtextxy ( 20, 165, "Advanced ( A )" ) ;
outtextxy ( 20, 175, "Expert ( E )" ) ;

/* get user's choice */
fflush ( stdin ) ;
if ( ( ch = getch() ) == 0 )
getch() ;

clearviewport() ;

/* return the choice made by the user */
return ( ch ) ;
}
/* draws a brick at the proper position */
drawbrick ( int lx, int ly )
{
rectangle ( lx, ly, lx + 31, ly + 9 ) ;
rectangle ( lx + 2, ly - 2, lx + 31 - 2, ly + 9 - 2 ) ;
floodfill ( lx + 1, ly + 1, 2 ) ;
}


/* draws bricks at the start of the game */

bricks()
{
int i, j, lx = 0, ly = 0 ;

for ( i = 0 ; i < 5 ; i++ )  /* 5 rows */
{
for ( j = 0 ; j < 20 ; j++ )  /* 20 columns */
{
/* draw a brick at appropriate coordinates */
drawbrick ( lx, ly ) ;

lx = lx + 32 ;
}

lx = 0 ;
ly = ly + 10 ;
}
}


/* erases the specified brick */
erasebrick ( int b, int l )
{
/* b - brick number, l - layer */

setcolor ( BLACK ) ;
rectangle ( b * 32, l * 10, ( b * 32 ) + 31 , ( l * 10 ) + 9 ) ;
rectangle ( b * 32 + 1, l * 10, ( b * 32 ) + 31 - 1, ( l * 10 ) + 9 - 1 ) ;
rectangle ( b * 32 + 2, l * 10, ( b * 32 ) + 31 - 2, ( l * 10 ) + 9 - 2 ) ;
setcolor ( WHITE ) ;
}


main()
{
union REGS ii, oo ;
int ballx, bally, paddlex, paddley, dx = 1, dy = -1, oldx, oldy ;
int gm = CGAHI, gd = CGA, playerlevel ;
int i, flag = 0, speed = 25, welldone = NO, score = 0, chance = 4, area ;
int layer[5] = { 10, 20, 30, 40, 50 }, limit = 50, currentlayer = 4 ;
char *p1, *p2 ;

/* initialise the graphics system */
initgraph ( &gd, &gm, "c:\\Turboc3\\BGI" ) ;

/* get the maximum x and y screen coordinates */
maxx = getmaxx() ;
maxy = getmaxy() ;

/* calculate center of screen */
midx = maxx / 2 ;
midy = maxy / 2 ;

/* display opening screen and receive player's level */
playerlevel = mainscreen() ;

/* set speed of ball as per the level chosen */
switch ( playerlevel )
{
case 'A' :
case 'a' :
speed = 15 ;
break ;

case 'E' :
case 'e' :
speed = 10 ;
}

/* draw the bricks, the paddle and the ball */
rectangle ( 0, 0, maxx, maxy - 12 ) ;
bricks() ;
rectangle ( midx - 25, maxy - 7 - 12, midx + 25, maxy - 12 ) ;
floodfill ( midx, maxy - 1 - 12, 1 ) ;
circle ( midx, maxy - 13 - 12, 12 ) ;
floodfill ( midx, maxy - 10 - 12, 1 ) ;

/* allocate memory for storing the image of the paddle */
area = imagesize ( midx - 12, maxy - 18, midx + 12, maxy - 8 ) ;
p1 = (char*)malloc ( area ) ;

/* allocate memory for storing the image of the ball */
area = imagesize ( midx - 25, maxy - 7, midx + 25, maxy - 1 ) ;
p2 = (char*)malloc ( area ) ;

/* if memory allocation unsuccessful */
if ( p1 == NULL || p2 == NULL )
{
puts ( "Insufficient memory!!" ) ;
exit ( 1 ) ;
}

/* store the image of the paddle and the ball into allocated memory */
getimage ( midx - 12, maxy - 7 - 12 - 12 + 1, midx + 12, maxy - 8 - 12, p1 ) ;
getimage ( midx - 25, maxy - 7 - 12, midx + 25, maxy - 1 - 12, p2 ) ;

/* store current position of the paddle and ball */
paddlex = midx - 25 ;
paddley = maxy - 7 - 12 ;
ballx = midx - 12 ;
bally = maxy - 7 - 12 + 1 - 12 ;

/* display balls in hand ( initially 3 ) */
gotoxy ( 45, 25 ) ;
printf ( "Balls Remaining:" ) ;
for ( i = 0 ; i < 3 ; i++ )
{
circle ( 515 + i * 35, maxy - 5, 12 ) ;
floodfill ( 515 + i * 35, maxy - 5, 1 ) ;
}

/* display initial score */
gotoxy ( 1, 25 ) ;
printf ( "Your Score:   %4d", score ) ;

/* select font and alignment for displaying text */
settextjustify ( CENTER_TEXT, CENTER_TEXT ) ;
settextstyle ( SANS_SERIF_FONT, HORIZ_DIR, 4 ) ;

while ( 1 )
{
flag = 0 ;

/* save the current x and y coordinates of the ball */
oldx = ballx ;
oldy = bally ;

/* update ballx and bally to move the ball in appropriate direction */
ballx = ballx + dx ;
bally = bally + dy ;

/* as per the position of ball determine the layer of bricks to check */
if ( bally > 40 )
{
limit = 50 ;
currentlayer = 4 ;
}
else
{
if ( bally > 30 )
{
limit = 40 ;
currentlayer = 3 ;
}
else
{
if ( bally > 20 )
{
limit = 30 ;
currentlayer = 2 ;
}
else
{
if ( bally > 10 )
{
limit = 20 ;
currentlayer = 1 ;
}
else
{
limit = 10 ;
currentlayer = 0 ;
}
}
}
}

/* if the ball hits the left boundary, deflect it to the right */
if ( ballx < 1 )
{
music ( 5 ) ;
ballx = 1 ;
dx = -dx ;
}

/* if the ball hits the right boundary, deflect it to the left */
if ( ballx > ( maxx - 24 - 1 ) )
{
music ( 5 ) ;
ballx = maxx - 24 - 1 ;
dx = -dx ;
}

/* if the ball hits the top boundary, deflect it down */
if ( bally < 1 )
{
music ( 5 ) ;
bally = 1 ;
dy = -dy ;
}

/* if the ball is in the area occupied by the bricks */
if ( bally < limit )
{
/* if there is no brick present exactly at the top of the ball */
if ( bri[currentlayer][ ( ballx + 10 ) / 32 ] == 1 )
{
/* determine if the boundary of the ball touches a brick */
for ( i = 1 ; i <= 6 ; i++ )
{
/* check whether there is a brick to the right of the ball */
if ( bri[currentlayer][ ( ballx + i + 10 ) / 32 ] == 0 )
{
/* if there is a brick */
ballx = ballx + i ;
flag = 1 ;
break ;
}

/* check whether there is a brick to the left of the ball */
if ( bri[currentlayer][ ( ballx - i + 10 ) / 32 ] == 0 )
{
ballx = ballx - i ;
flag = 1 ;
break ;
}
}

/* if the ball does not touch a brick at the top, left or right */
if ( !flag )
{
/* check if the ball has moved above the current layer */
if ( bally < layer[currentlayer - 1] )
{
/* if so, change current layer appropriately */
currentlayer-- ;
limit = layer[currentlayer] ;
}

/* put the image of the ball at the old coordinates */
putimage ( oldx, oldy, p1, OR_PUT ) ;

/* erase the image at the old coordinates */
putimage ( oldx, oldy, p1, XOR_PUT ) ;

/* place the image of the ball at the new coordinates */
putimage ( ballx, bally, p1, XOR_PUT ) ;

/* introduce delay */
delay ( speed ) ;

/* carry on with moving the ball */
continue ;
}
}

/* control comes to this point only if the ball is touching a brick */
music ( 4 ) ;  /* play music */

/* erase the brick hit by the ball */
erasebrick ( ( ballx + 10 ) / 32, currentlayer ) ;

/* if the brick hit happens to be on the extreme right */
if ( ( ballx + 10 ) / 32 == 19 )
line ( maxx, 0, maxx, 50 ) ;  /* redraw right boundary */

/* if the brick hit happens to be on the extreme left */
if ( ( ballx + 10 ) / 32 == 0 )
line ( 0, 0, 0, 50 ) ;  /* redraw left boundary */

/* if the brick hit happens to be in the topmost layer */
if ( currentlayer == 0 )
line ( 0, 0, maxx, 0 ) ;  /* redraw top boundary */

/* set appropriate array element to 1 to indicate absence of brick */
bri[currentlayer][ ( ballx + 10 ) / 32 ] = 1 ;

bally = bally + 1 ;  /* update the y coordinate */
dy = -dy ;  /* change the direction of the ball */
score += 5 ;  /* increment score */
gotoxy ( 16, 25 ) ;
printf ( "%4d", score ) ;  /* print latest score */

/* if the first brick is hit during a throw */
if ( welldone == NO )
welldone = YES ;
else
{
/* for the consecutive bricks hit during the same throw */
outtextxy ( midx, midy, "Well done!" ) ;
music ( 1 ) ;
}
}

/* clear part of the screen used for displaying Well done message */
if ( bally > 50 && welldone == YES )
{
setviewport ( midx - 32 * 2.5, midy - 32 / 2, midx + 32 * 2.5, midy + 32 / 2, 1 ) ;
clearviewport() ;
setviewport ( 0, 0, maxx, maxy, 1 ) ;
welldone = NO ;
}

/* if the ball has reached the bottom */
if ( bally > 180 - 12 )
{
welldone = NO ;

/* if the paddle has missed the ball */
if ( ballx < paddlex - 20 || ballx > paddlex + 50 )
{
/* continue the descent of the ball */
while ( bally < 177 )
{
/* erase the image of the ball at the old coordinates */
putimage ( oldx, oldy, p1, XOR_PUT ) ;

/* put the image of the ball at the updated coordinates */
putimage ( ballx, bally, p1, XOR_PUT ) ;

/* introduce delay */
delay ( speed ) ;

/* save the current x and y coordinates of the ball */
oldx = ballx ;
oldy = bally ;

/* update ballx and bally to move the ball in appropriate direction */
ballx = ballx + dx ;
bally = bally + dy ;
}

chance-- ;  /* decrement the number of chances */
score -= 20 ;  /* decrement 20 points for each ball lost */
gotoxy ( 16, 25 ) ;
printf ( "%4d", score ) ;  /* print latest score */
music ( 2 ) ;

/* erase one out of the available balls */
if ( chance )
putimage ( 515 + ( chance - 1 ) * 35 - 12 , maxy - 10, p1, XOR_PUT ) ;

/* if the last ball is being played */
if ( chance == 1 )
{
gotoxy ( 45, 25 ) ;
printf ( "Your last ball... Be careful!" ) ;
}

/* if all the balls are lost */
if ( !chance )
{
gotoxy ( 45, 25 ) ;
printf ( "Press any key...              " ) ;
outtextxy ( midx, midy, "I warned you! Try again" ) ;
music ( 3 ) ;

closegraph() ;
restorecrtmode() ;
exit ( 0 ) ;
}
}

/* if ball is collected on paddle */
music ( 5 ) ;
bally = 180 - 12 ;  /* restore the y coordinate of ball */
dy = -dy ;  /* deflect the ball upwards */
}

/* put the image of the ball at the old coordinates */
putimage ( oldx, oldy, p1, OR_PUT ) ;

/* erase the image of the ball at the old coordinates */
putimage ( oldx, oldy, p1, XOR_PUT ) ;

/* put the image of the ball at the upadted coordinates */
putimage ( ballx, bally, p1, XOR_PUT ) ;

/* if all the bricks have been destroyed */
if ( score == 500 - ( ( 4 - chance ) * 20 ) )
{
outtextxy ( midx, midy, "You win !!!" ) ;

if ( score < 500 )
outtextxy ( midx, midy + 30, "Try scoring 500" ) ;
else
outtextxy ( midx, midy + 30, "You are simply GREAT!" ) ;

music ( 3 ) ;

closegraph() ;
restorecrtmode() ;
exit ( 0 ) ;
}

/* introduce delay */
delay ( speed ) ;

/* if the user has pressed a key to move the paddle */
if ( kbhit() )
{
/* issue interrupt to obtain the ascii and scan codes of key hit */
ii.h.ah = 0 ;
int86 ( 22, &ii, &oo ) ;

/* put the image of the paddle at the old coordinates */
putimage ( paddlex, paddley, p2, OR_PUT ) ;

/* erase the image of the paddle at the old coordinates */
putimage ( paddlex, paddley, p2, XOR_PUT ) ;

/* if Esc key has been pressed */
if ( oo.h.ah == 1 )
exit ( 0 ) ;

/* right arrow key */
if ( oo.h.ah == 75 )
paddlex = paddlex - 20 ;

/* left arrow key */
if ( oo.h.ah == 77 )
paddlex = paddlex + 20 ;

/* if paddle goes beyond left boundary */
if ( paddlex < 0 )
paddlex = 0 ;

/* if paddle goes beyond right boundary */
if ( paddlex > 589 )
paddlex = 589 ;

/* put the image of the paddle at the proper position */
putimage ( paddlex, paddley, p2, XOR_PUT ) ;
}
}
}