|
From: Ioannis V. <no...@ya...> - 2001-01-02 12:44:07
|
do
{
scanf("%d", &quit);
}while(quit>40000);
Ioannis
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of Frazell
Thomas
Sent: Tuesday, January 02, 2001 4:24 AM
To: dev...@li...
Subject: [Dev-C++] Divide error
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 = 0;
int nbr;
char plus;
main()
{
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 = 40000;
// if statement to prevent the divide error if the var. a is zero
if (a == 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 <= 20000)
{
return 0;
}
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 = 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 = (a_2 - 4 * a * c);
b_2 = b_3 * 2;
b = b_3 - b_2;
div = 2 * a;
answer = (b + sroot) / div;
answer_2 = (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);
// While loop
do
{
puts("\n\nEnter 99 to quit ");
scanf( "%d", &nbr);
value[ctr] = nbr;
ctr++;
}while (ctr < 10 && nbr != 99);
return 0;
}
|