sample2.c

/*
 * add s to itself until the sum exceeds 100
 *
 * this program has a bug -- comments omitted to hide it
 * used to demonstrate static and dynamic debugging
 *
 * Matt Bishop, ECS 36A, Fall 2019
 */
#include <stdio.h>

int main(void)
{
	int i = 1, s;

	s = 3;
	while(i = 1){
		s += s;
		if (s > 100)
			i = 0;
	}

	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 2, 2024 at 12:13PM

You can get the raw source code here.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh