Categories
Humor

Can u get rid of this bug in the code below?

/* add.c
* a simple C program
*/

#include <stdio.h>
#define LAST 10

int main()
{
int i, sum = 0;

for ( i = 1; i <= LAST; i++ )
{
sum += i;
} /*-for-*/
printf(“sum = %d\n”, sum);
return 0;
}

Forwarded by Savitha

17 replies on “Can u get rid of this bug in the code below?”

Or as put forward by Mustrum Ridcully Archchancellor of the Unseen University
The fastest way to deal with problems is to ignore them. If they are important enough someone will come to you with it rather than leaving a note.

It may be that if the value of LAST is increased the code will not work as sum will exceed the maximum integer value allowed. This will happen even LAST is much less than the maximum integer.

Otherwise I don’t think there is a clue. The issue is similar to the bug in JDK (resolved now) to find average of two integers.

Nice ankur, I thought that it was related to the flying bug, but it looks like my proxy server has banned the gif and so it was not visible here. I therefore thought that there is something important other than humor.

Just want to say your article is as asnonishitg. The clearness in your post is just cool and i could assume you are an expert on this subject. Well with your permission let me to grab your feed to keep up to date with forthcoming post. Thanks a million and please continue the enjoyable work.

Leave a Reply

Your email address will not be published.