|
From: Frazell T. <fr...@fl...> - 2001-01-02 02:23:51
|
I managed to fix the only bug i know of in my program i used an if =
statement but if the user enters an exit value over 40000 the program =
will then continue to execute reliving the bug if anyone can help me fix =
this new bug i would be greatly appreciative
-------------------------------------PROGRAM SOURCE =
CODE-------------------------------------------------------
// Quadrilatric equation calculater
// Written by: Frazell Thomas
#include <stdio.h>
#include <math.h>
#include <windows.h>
int a,a_2,b,c,d,answer,sroot,answer_2,b_2,b_3,div,quit,quit1;
int value[10];
int ctr =3D 0;
int nbr;
char plus;
main()
{ =20
MessageBox (NULL, "This is Q-Calc BETA 1.1
Visit http://www.FrazellThomas.com" , "Q-Calc", 0 + MB_ICONASTERISK);
// Cpoyright and author information
// If you alter this program you must list me in the credits
// As the lead developer on this piece of software
// I would also request that any version you release
// Be forwarded to me at fra...@ya...
// To keep me from re-inventing the wheel (programming code u =
already
// Done)
// This software it under the GNU public license
printf("This program is designed to do quadratic equations =
only.\n");
printf("You are free to use this software as stated under the =
GNU\n");
printf("Public License (Avalible at GNU.org).\n\n");
printf("Version: Beta 1.1 12/12/2000 8:00PM EST.\n");
printf("Programmer: Frazell Thomas\n");
printf("Please visit http://www.frazellthomas.com\n\n");
// Input From User
printf("Please enter the number used to represent varible A: ");
scanf("%d", &a);
quit =3D 40000;
// if statement to prevent the divide error if the var. a is zero
if (a =3D=3D 0)
{
printf("\n\nYou entered Zero for varible A which will result =
in\n");
printf("\n\nNo possible answer please exit the program and run =
again\n");
printf("\n\nBut do not use A Zero for varible A\n");
printf("\nPlease Enter 33 To Quit\n");
scanf("%d", &quit);
}
if (quit <=3D 20000)
{=20
return 0;
} =20
printf("Please enter the number used to represent varible B: ");
scanf("%d", &b_3);
printf("Please enter the number used to represent varible C: ");
scanf("%d", &c);
//Raises varible b to the second power
a_2 =3D pow(b_3, 2);
// This is the part of out calc prog that does the work :O)
// please alter + sign before var. c to a - if needed and vic =
versa
sroot =3D (a_2 - 4 * a * c);
b_2 =3D b_3 * 2;
b =3D b_3 - b_2;
div =3D 2 * a;
answer =3D (b + sroot) / div;
answer_2 =3D (b - sroot) / div;
// Prints the answer
printf("\nThe Answer Is %d and %d\n ", answer, answer_2);
printf("\nThe square root of %d in this problem was %d\n ", b_3, =
sroot);
printf("\n%d To the second power is %d ", b_3, a_2);
=20
// While loop =20
do
{
puts("\n\nEnter 99 to quit ");
scanf( "%d", &nbr);
value[ctr] =3D nbr;
ctr++;
}while (ctr < 10 && nbr !=3D 99);
return 0;
}
|