Simple C Puzzle

utzoo!decvax!harpo!seismo!dmy utzoo!decvax!harpo!seismo!dmy
Wed Dec 29 08:31:40 AEST 1982


/* This is a (fairly) simple puzzle.
   Why does this program print "1" instead of "2"?
   Note: (1/1)+1 == 2 not 1
*/

main()
{
int a,b,*p;
	b= 1;
	p= &b;
	a= b/*p;
	++a /* oh? */;
	printf("%d\n",a);
}

/*
--dmy--
*/



More information about the Comp.lang.c mailing list