Code from Lab 10-9-01

#include <stdio.h>
#include <math.h>

void flushBuffer(void);

void main() {

	char inputChar;
	double num1;
	int conversions;

	printf("%s", "Do you want to do some math? (y/n) ");
	scanf("%c", &inputChar);
	flushBuffer();

	while (inputChar == 'Y' || inputChar == 'y') {

		printf("%s", "Enter a number: ");
		conversions = scanf("%lf", &num1);
		flushBuffer();

		if (conversions == 0) {
			printf("%s\n", "Bad input");
		}
		else {
			printf("You entered: %f\n", num1);
		}

		printf("%s", "Do you want to do some more math? (y/n)");
		scanf("%c", &inputChar);
		flushBuffer();
}

	/*
	// imaginary number situation
	float a = 1;
	float b = 2;
	float c = 3;

	double firstTerm;
	double secondTerm;

	double discriminant = b * b - 4 * a * c;

	if (discriminant < 0) {
		firstTerm = -b / (2 * a);
		secondTerm = sqrt(-discriminant) / (2 * a);

		printf("%f + %fi\n", firstTerm, secondTerm);
	}
	else {
		printf("hello");
	}
	*/

}

void flushBuffer(void) {
	char flushChar;

	while ((flushChar = getchar()) != '\n')
	;
}