Monday, November 17, 2008

Bug in C !!!!

This happened during my training days. First day of C programming, before that the toughest C program I ever coded in my life is prime number.(still I don’t get that logic, I just memorized and vomited in the exam). After day 1 of some basic introduction, I thought of writing a program.. This program gives an option for addition, subtraction, multiplication and division of two numbers. I wrote the program and started testing it.

Everything was fine, I checked for addition of two numbers. 10+12 = 22, then 3+4 = 7…wow, my first program and its running fine. Then I thought of testing the system capacity. I gave some large numbers and then also it was returning the right results. Then I gave this number 3.4 , 4.6 for addition I was expecting 8 and it spitted 7 on my face !!!!

Now, I am bit surprised, I tried various numbers and everything worked well except 3.4 and 4.6. Now, I was really wondering whether I have invented a bug in the C programming ??? then the weird thoughts like : me solving the bug and getting noticed, then I get company level recognition, then US people wants to know how I debugged it , so I m making a trip to US and what not, at last ending up meeting Bill Gates, Steve Jobs and Larry Page.

It was uncontrollable pleasure for few mins and then I informed my fellow batch mate about the bug. She was in grave shock hearing what I have said. She was delighted and at that time I was looking like million bucks in front of her (aiiiaaaaa, Vaaranam Aaiyiram padam paathathu idukaachum use aagudey !!!!) then she looked into my code. The next minute she gave an awkward look at me as if I’m the biggest moron in this world. I asked her:

Me: Hey what happened?????
She: Have you ever coded before in your life ????
Me: No, whats the matter ????
She: well, u declared the variable as "int" and you are trying to add a "float" values…


Well, do I have to say how I looked at that time ???? it’s left for your imagination, but certainly it took me a week to face her again!!!!!

PS: after that only I came to know the variable types in C
PPS: that was the first and last time I coded something !!!!
PPPS: still now, at some weird hours, I believe what I coded is absolutely right !!!!!!!!!

2 comments:

Agni said...

Was able to make out the mistake u did as I read through the post! :) Aanaalum idhukku Steve Jobs level la thinka pannadhu over dhaan...

ஸ்ரீனிவாசன் said...

ellam oru ejitement thaan maapla !!!!

athukapuram kaenai paya maadiri valinjadu sema comedy a irunduchuda !!!!!!!!