Saturday, March 15, 2008

Spot the Bugs........

Debugging is the systematic process of removing bugs in you program. If these bugs are not removed then it may result in serious damages. Here are some code snippets which consists of a few bugs. Try to debug it without looking at the answers.

Question 1

1    #include "stdio.h"
3 #define N 5
4 int Weight[N] = { 3, 1, 4, 5, 2 };
6 int rand_choice()
7 {
8 int i, choice = 0;
9 int k = rand() % (3*N);
10 for( i = 0; i <= N; i++ ) 11 {
12 if( k >= 0 ) choice = i;
13 k -= Weight[i];
14 }
15 return choice;
16 }
17 int voting_machine( int vote )
18 {
19 if( vote == 1 ) return rand_choice();
20 else return vote;
21 }

Question 2

1 #include "stdio.h"
3 class Animal
4 { public:
5 virtual void init() {}
6 Animal() { init(); }
7 };
9 class GroundHog : public Animal
10 { public:
11 const char *appears;
12 virtual void init() { appears = "Feb 2"; }
13 };
15 int main()
16 {
17 GroundHog x;
18 printf( "Ground hogs appear %s\n" , x.appears );
19 return 0;
20 }

Question 3

1    #include "stdio.h"
3 const int march[31] = {
4 8, 5, 7, 2, -4, -14, -7, -4, -2, 0,
5 0, 2, 5, 7, 2, -4, -14, -7, -4, -2,
6 1, 7, 2, 2, -2, -3, -4, 6, -4, 3, 9 };
8 int main()
9 {
10 unsigned i, count = 31;
11 int sum = 0;
13 for( i = 0; i < style=""> {
15 sum += march[ i ];
16 }
17 printf( "The average low temperature in March was"
18 " %d degrees\n", sum / count );
19 return 0;
20 }

Question 4

1    #include "stdio.h"
2 class R
3 {
4 public:
5 int k, depth;
6 R() :k(0), depth(0) {}
7 const R& operator=( const R & r )
8 {
9 if( this != &r )
10 { k = r.k; depth = r.depth+1; }
11 return r;
12 }
13 };
14 int main()
15 {
16 R r1, r2, r3;
17 r1 = r2 = r3;
18 printf( "%d %d %d\n",
19 r1.depth, r2.depth, r3.depth );
20 }

Question 5

1    #include "stdio.h"
2 #include "string.h"
4 char husband[] = " Charlie";
5 char wife[] = " Sandra";
7 char *trim( char *s )
8 { // removing leading blanks
9 char *p = new char[strlen(s)+1];
10 strcpy( p, s );
11 while( *p == ' ' ) p++;
12 strcpy( s, p );
13 delete p;
14 return s;
15 }
17 int main()
18 {
19 printf( "...pleased to announce the wedding of"
20 " %s and %s\n", trim(husband), trim(wife) );
21 return 0;
22 }


1. In line 13, a warning generated for possible access for out of bounds pointer

2. In line 6, a warning is generated for the call of a virtual function 'Animal:init(void)' within a constructor or destructor

3. In line 18, a warning is generated for 'signed-unsigned' mix with divide.

4. In line 11, the assignment operator must return *this

5. In line 13, improper deallocation of the pointer. It should be 'delele []p' instead of 'delete p'

Friday, March 14, 2008

Free C# and ASP.NET Tutorial

C# is an object oriented programming language developed by Microsoft. C# is a simple and robust language that can be used to develop stand alone as well as web applications. The biggest advantage of C# is that it supports more than 60 compilers. In other words with a single IDE(Integrated Development Environment) we can write programs in more than 60 languages. The CLR (Common Language Runtime) makes the programs written in C# portable. Unlike its predecessors like C and C++ which does not have automatic garbage collection, C# automatically collects the garbage and prevents memory leaks. Multiple Inheritance is not supported but a class may implement any number of interfaces.

ASP.NET is a web application framework that is developed and marketed by Microsoft. It allows users to create their own web sites. The difference between ASP.NET and ASP(Active Server Pages) is that ASP demands good scripting knowledge such as VB Script etc. In case of ASP.NET the programmer need not know scripting and still be able to generate websites which are robust.

For a beginner it would be bit difficult to learn the syntax and semantics of C# as it consists of a large number of built in name spaces which perform a lot of functions. Recently i came across an online tutorial which helped me a lot in understanding the basics of C#.Net. The tutorial consists of powerpoint presentations which clearly depict the features such as ADO.NET ( Database connectivity) and ASP.NET. The tutorial also consists of sample code snippets which can really help the beginners to a great extent. Click here to download the tutorial.

I hope that this tutorial would be useful to you!!!!!

Thursday, March 13, 2008

An Indian girl wins Intel Science Talent Prize

An Indian named girl Shivani Sud won the top prize at the prestigious Intel Science Talent Search competition in the U.S. on Tuesday, March 11 2008. She gets a scholarship worth of 100,000$ from the Intel Foundation. This is the first and foremost occasion that an Indian girl has won the top prize which is often termed as Junior Nobel Prize. Shivani Sud had submitted a project to Intel Corporation that is aimed in identifying stage II colon cancer patients at high risk for recurrence and the best therapeutic agents for treating their tumors. The incident which inspired her to work on a project like this was that one of her immediate family member was found to have brain tumor and was at last saved by all the doctors.

Colo rectal cancer, also called colon cancer or large bowel cancer, includes cancerous growths in the colon, rectum and appendix. It is the third most common form of cancer and the second leading cause of cancer-related death in the Western world. Colo rectal cancer causes 655,000 deaths worldwide per year. These mushroom-like growths are usually benign, but some may develop into cancer over time. The majority of the time, the diagnosis of localized colon cancer is through colonoscopy. Therapy is usually through surgery, which in many cases is followed by chemotherapy.

The standard method of characterizing colon cancer relies on visual information, including size, degree of metastasis and microscopic structure. Shivani's gene model for predicting the recurrence of colon cancer instead uses gene expression profiles to link multiple genetic events that characterize various tumor types. She created her model using two public data sets containing 125 patient samples and coupled it with clinical data to plot statistically significant survival curves. She then used her model to identify drugs that may be effective in treating stage II colon cancer. The Science talent search is a prestigious competition and winning in such an event has brought noble laureates to her family and to India.

The chairman of Intel Craig Barrett congratulated Shivani for her achievement. Thus Shivani has made both her family and India proud by the work she has done which no one might have thought even in their wildest of dreams.

Is this the end of the road for Indian Hockey, Chak De or Chuck De ? ?

Whats wrong with Indian Hockey team at the moment ? This is the first time that the Indian Hockey team has failed to qualify for the Olympics after nearly 80 years, that's pretty long back, even before free India. That shows what the kind of passion and love for the sport that they had.

But what happened to the passion and love for the beautiful game now ? The once considered as "INVINCIBLE" who have won eight gold medals, have miserably failed to even book a spot in Olympics. There has been a lot of speculations and debates and special interviews going on in media to know what really costs us the Olympics. But is these debates really the need of the hour ? In my opinion a certain no. We have to rather focus on developing the game. Although cricket is a religion here, we should not forget our national game.

The infrastructure of the hockey has to be improved still. It is not upto the world class standards. Infrastructure is very much necessary and important for development of the game. Also IHF or the Indian Hockey Federation has to take more responsibility and more care to develop our national game. When asked about the loss, each one in the hockey feternity is very quick to throw the blame on one another, but the end sufferer is the game of hockey.

Also i have sympathy for our players, because the media today are like that, when done well, they give all credit to them and if they do not do well , then they are gone. But it was very surprising rather sad, to see how each one throws blame on each other. In fact, the coach went to the extent of blaming the umpires for the loss, sounds like somewhere we have heard this, Yes in our own religion called cricket. The coach has put the blame on players too, in fact he was partly right, a coach can only formulate plans and its the players who have to execute them, and as always in Indian Hockey, the execution went wrong yet again.

If this was not enough for a blow to India, the world hockey committee has decided to reconsider the decision of holding the hockey world cup in India. If they decide to not to host it in India, then its a severe beating for us. Is the administration really the fault ? Not only former Indian players even former International players have said the same thing that it was due to poor planing and administration that has cost India its Olympic place. Darryl D'Souza, a former Olympian has said that the team has not at all prepared well, it seemed that we have practiced against western Australia and tamil nadu teams. Oh God, to qualify for Olympics we practiced against such minor teams. This shows that the administration is the problem. Even Gill, who is President of IHF is so adamant that it was not his fault, he seems to say that administration is not a problem.

Finally, whatever the reason may have been but its over now, India cannot participate in this year's Beijing Olympics. But we should never lose heart. It will not take more time to see the Indian hockey team become invincible once again. Even some former players have said to leave the debacle behind and should focus on the infrastructure and prepare for the 2012 London Olympics from now itself. I guess what they said is true, at least from now on the IHF should take proper care of Indian Hockey and make sure that India not only qualify for next Olympics but start a GOLDEN PERIOD OF INDIAN HOCKEY by winning the gold medal. I hope every one like me would like to say "CHAK DE" and never "CHUCK DE"

Wednesday, March 12, 2008

Is IPL a boon to Cricket or a curse..........

As everyone is aware IPL (Indian Premier League) is the latest sensation that has been put forth in the world of cricket. Created by BCCI and sanctioned by ICC, IPL is a twenty-twenty cricket competition. There are totally 8 teams in the league and each team will play the other 7 teams home and away, the top four teams at the end of the group stages will proceed through to the semi finals. The magnitude of each team was confirmed when the winning bidders for the eight franchises were announced on January 24, 2008. The official list of bidders consists of Mukesh Ambani & Reliance Industries(Mumbai Indians), Vijay Malaya & U.B group(Bangalore Royal Challengers), Shah Rukh Khan & Red Chillies Entertainment(Kolkata Night Riders), Deccan Chronicle(Hyderabad), India Cements(Chennai Super Kings), GMR Holdings(Delhi Daredevils), Preity Zinta & Ness Wadia(Mohali), Emerging India(Rajasthan Royals). The total auction fetched around 720 million US $. Due to the presence of icon players like Sachin Tendulkar, MS Dhoni etc IPL is expected to draw more people to watch the matches. The telecast rights were given to India's Sony Television group and Singapore based World Sport Group. In sum IPL has pumped a record revenue of about 1026 million US $.

Such a big sum can act like a double headed sword. The positive aspect of it is that all the low profile cricket players can earn more money in a very quick span of time and the excess money can be used to improve the cricket-infrastructure such as ground maintenance etc all over the country. The negative aspect of this is that when upcoming players with good talent and potential see such a huge some of money in their hands, they tend to get lazy and lose the focus in playing the game. Nowadays cricket players tend to endorse a lot of products and hence they completely get diverted from the game. The other disadvantage that is agreed by a lot of people is that sufficient attention is not given to other sports such as football, hockey, badminton etc. So there is very less scope for other sports and sportsmen to grow in our country. For example, a cricketer is paid several lakhs or even crores by the BCCI every year, it is found that a hockey player is paid only Rs 5000 per match. Even if a cricketer fails for several matches in a row he is bound to get the same amount of money which he was offered, whereas a hockey player loses Rs 1000 every match if he fails to score a goal. This shows the plight of other sports in our country.

Thus to conclude with, though IPL has huge entertainment value associated with itself it is very important that team spirit and "playing for the nation" attitude is maintained. If money is given is more importance then IPL would act like a curse to Cricket.

Tuesday, March 11, 2008

N R NARAYANA MURTHY: An Inspirational Leader for Young and Aspiring Enterpreneurs.

Narayana Murthy is the Non-Executive Chairman and Chief Mentor of Infosys Technologies Limited. He is a living legend and an epitome of the fact that honesty, transparency, and moral integrity are not at variance with business acumen. He set new standards in corporate governance and morality when he stepped down as the Executive Chairman of Infosys at the age of 60.

Born on August 20, 1946, N.R. Narayana Murthy is a B.E. Electrical from University of Mysore (1967) and M.Tech from IIT Kanpur (1969). Narayana Murthy began his career with Patni Computer Systems in Pune. In 1981, Narayana Murthy founded Infosys with six other software professionals. In 1987, Infosys opened its first international office in U.S.A.

With the liberalization of Indian economy in 1990s, Infosys grew rapidly. In 1993, the company came up with its IPO. In 1995, Infosys set up development centers across cities in India and in 1996, it set up its first office in Europe in Milton Keynes, UK. In 1999, Infosys became the first Indian company to be listed on NASDAQ. Today (in 2006), Infosys has a turnover of more than $ 2billion and has employee strength of over 50,000. In 2002, Infosys was ranked No. 1 in the "Best Employers in India 2002" survey conducted by Hewitt and in the Business World's survey of "India's Most Respected Company." Conducted in the same year.

Along with the growth of Infosys, Narayana Murthy too has grown in stature. He has received many honors and awards. In 2000, he was awarded the Padma Shri, a civilian award by the Government of India. In June 2000, Asia week magazine featured him in a list of Asia's 50 Most Powerful People. In 2001, Narayana Murthy was named by TIME/CNN as one of the 25 most influential global executives. He was the first recipient of the Indo-French Forum Medal (2003) and was voted the World Entrepreneur of the Year - 2003 by Ernst and Young. The Economist ranked Narayana Murthy eighth on the list of the 15 most admired global leaders (2005) and Narayana Murthy also topped the Economic Times Corporate Dossier list of India's most powerful CEOs for two consecutive years - 2004 and 2005. Recently he was awarded the Padma Vibushan, a second highest civilian award by India.

Though his profile is great he is a very simple person by nature and he wants to instill social values among the people of India which is evident from his contributions to the society. During all his meetings with the news channels he insists the youngsters to be entrepreneurs which would provide employment to a lot of people and in turn help India's economic status to a great extent. Thus to conclude with he is a person who leads as an example for young and aspiring entrepreneurs.


A puzzle is a problem that challenges the skill and ability of a person. In a basic puzzle you piece together objects in a logical way in order to come up with the desired shape, picture or solution.Puzzles are often contrived as a form of entertainment, but they can also stem from serious mathematical or logistical problems. In such cases, their successful resolution can be a significant contribution to mathematical research. Solutions to puzzles may require recognizing patterns and creating a particular order. People with a high inductive reasoning aptitude may be better at solving these puzzles than others. Puzzles based on the process of inquiry and discovery to complete may be solved faster by those with good deduction skills.

Here are some puzzles that i found interesting and entertaining. Try to answer the questions without looking at the answers. I hope that it would be interesting!!!!!!!

1. Make the left arrangement look like the right arrangement by moving only 3 circles from the left arrangement.

2. Take a look at the sketch and tell how many triangles are there in the figure.

3. Here is an epitaph of the celebrated Greek mathematician of 250 A.D., Diophantus. Can you calculate his age from this?


4. It was a day to celebrate and on this day a whole family met. The gathering consisted of one-grandfather, one grandmother, two fathers, two mothers, four children, 3 grand children, one brother, 2 sisters, 2 sons, 2 daughters, 1 father in law, 1 mother in law, 1 daughter in law. The gathering all together had 7 members. How can you explain it?

5. Is a 'size-16' knitting needle twice as thick as 'size-8' knitting needle?


1. Assume that each ball is numbered as 1,2,3.... etc in ascending order in the left arrangement. Now to get the right arrangement just move ball 9 in place of ball 1, ball 7 in place of ball 2 and ball 10 in place of ball 3.

2. There are 47 different triangles.

3. Let us assume a is 'Diophantus' age. So a/6 + a/12 + a/7 + 5 + a/2 + 4 = a. On Solving this equation we get a=84. Hence Diophantus lived to be 84 years old.

4. There were 2 girls and a boy, their father and mother, and their father's father and mother.

5. No. Knitting needles confirm to the Standard Wire Gauge sizes and the larger the S.W.G number, the smaller is the diameter of the wire.