Get help on this challenge


Please read this explanation before attempting debugging challenges.

The following is C code that gives the wrong output. Figure out why and suggest a reasonable solution:

// Fun program
// By ynori7

//This function takes the sum of the three inputs and stores it into the first variable
void fun(int *a, int *b, int *c)

int main()
	int a=2, b=3, c=4, d=5, e=6;
	fun(&a, &b, &c);
	fun(&c, &d, &e);
	fun(&a, &b, &a);
	printf("%d %d %d %d %d", a, b, c, d, e);
	return 0;
/* Oh noes! The program is giving me this output:
 * "24 3 15 5 6" but it looked at it very carefully
 * and it should be "21 3 15 5 6". What could possibly
 * be wrong? */

Downloadable source code can be found here.

You must be logged in to play. Login or register here

Challenge by ynori7.