Quiz for Novice to Intermediate C Users

Rick Buls buls at dataio.UUCP
Thu Apr 18 08:35:51 AEST 1985


/*
**	Ok netland its C quiz time. Not to be found in 
**	"The C Puzzle Book" by Alan Feuer.
**	
**	Below is a C program that tests the famous foo.
**	
**	The question:	what does the following program print?
**	
**	Spoiler:	The answer is NOT "foo returns 5"
**	
*/

#define	dum(x)		/* empty debug macro */

main()
{
	printf("foo returns %d\n",foo());  /* print answer */
}

foo()
{
	int a,b,*p= &a;		/* p points to a */

	b=10;
	*p=2;			/* set a to 2 */
	a=b/*p;			/* div b by contents of pointer(ie a) */
	dum(a);
	return(a);
}



More information about the Comp.lang.c mailing list