div.c

/*
 * demonstrate what happens when you divide by 0
 * 
 * Matt Bishop, ECS 36A
 * April 4, 2024	original version
 */
#include 

int main(void)
{
	int x = 0;	/* divisor */

	/* divide 100 by 0 and print the result */
	x = 100/x;
	/* you never get here; it crashes */
	printf("%d\n", x);

	/* say goodnight! */
	return(0);
}

UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: [email protected]
ECS 36A, Programming & Problem Solving
Version of April 8, 2024 at 9:31AM

You can get the raw source code here.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh