|
From: Frazell T. <fr...@fl...> - 2001-01-02 05:28:35
|
Sorry i was an idiot i wasted everyones time trying to fix a bug that =
really was fixed by the lines of code i used to quit my prog. already =
well below is the updated code if anyone has ideas on how it can be more =
simple to present to other developers let me know
--------------------------------------PROGRAM =
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)
{
do
{
puts("\nSorry you entered 0 this will result in an error =
try again.");
puts("\n\nEnter 99 to quit: ");
scanf( "%d", &nbr);
value[ctr] =3D nbr;
ctr++;
}
while (ctr < 10 && nbr !=3D 99);
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;
}
|
|
From: angel d. <sci...@ho...> - 2007-12-23 05:19:57
|
I already got the answer to the message question. thanks to you all. _________________________________________________________________ Share life as it happens with the new Windows Live. http://www.windowslive.com/share.html?ocid=3DTXT_TAGHM_Wave2_sharelife_1220= 07= |
|
From: Hoo H. <hoo...@ho...> - 2001-01-02 08:55:34
|
hi,
there are few things I would like to comment:
1. to solve a quadratic equation ax^2 + bx + c =3D 0, 2 criteria have to =
be met.
(a) a <> 0 (which you have done)
(b) b^2 >=3D 4 * a * c , or else the solution would be a pair of =
complex numbers
2. your did not take the square root for sroot, which is sroot =3D sqrt =
(a_2 - 4 * a * c)
3. the statement:
b_2 =3D b_3 * 2;
b =3D b_3 - b_2;
is a bit redundant.
since
b_2 =3D b_3*2
thus=20
b =3D b_3 - b_2
=3D> b =3D b_3 - ( 2 * b_3)
=3D> b =3D - b_3
I have changed your source, and simply quite number of places, hope this =
may help.
=20
--------------------------------------PROGRAM =
CODE---------------------------------------------------------------------=
----------------------------------------
=20
// Quadrilatric equation calculater
// Written by: Frazell Thomas
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <windows.h>
int a,b,c;
float sroot, divide, answer_1, answer_2;
double determinent;
int main()
{ =20
MessageBox (NULL, "This is Q-Calc BETA 1.1
=20
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);
// if statement to prevent the divide error if the var. a is zero
if (a =3D=3D 0)
{
printf("\nSorry you entered 0 this will result in an error try =
again.");
printf("\nPlease enter the number used to represent varible A: =
");
printf("\nEnter 0 again to quit: ");
scanf("%d", &a);
if (a=3D=3D0)
{
return 0;
}
} =20
printf("\nPlease enter the number used to represent varible B: ");
scanf("%d", &b);
printf("\nPlease enter the number used to represent varible C: ");
scanf("%d", &c);
determinent =3D (pow(b,2) - 4*a*c);
if (determinent < 0)
{
printf("\nSorry b^2 < 4*a*c , unable to solve this quadratic =
equation\n");
system("Pause");
return 0;=20
}
sroot =3D sqrt(determinent);
divide =3D 2 * a;
answer_1 =3D (-b - sroot) / divide;
answer_2 =3D (-b + sroot) / divide;
=20
// Prints the answer
printf("\nThe Answer Is %.4f and %.4f\n ", answer_1, answer_2);
=20
system("Pause"); =20
}
----- Original Message -----=20
From: Frazell Thomas=20
To: dev...@li...=20
Sent: Tuesday, January 02, 2001 1:27 PM
Subject: [Dev-C++] Sorry
Sorry i was an idiot i wasted everyones time trying to fix a bug that =
really was fixed by the lines of code i used to quit my prog. already =
well below is the updated code if anyone has ideas on how it can be more =
simple to present to other developers let me know
--------------------------------------PROGRAM =
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)
{
do
{
puts("\nSorry you entered 0 this will result in an =
error try again.");
puts("\n\nEnter 99 to quit: ");
scanf( "%d", &nbr);
value[ctr] =3D nbr;
ctr++;
}
while (ctr < 10 && nbr !=3D 99);
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;
}
|
|
From: Frazell T. <fr...@fl...> - 2001-01-02 10:27:59
|
Thank you very much i like what you did to correct my divide error bug =
it was what i wanted to do all along :O) i guess my mistakes showed im =
truley a newbie i will add you to my prog. thanks again
----- Original Message -----=20
From: Hoo Hong=20
To: dev...@li...=20
Sent: Tuesday, January 02, 2001 3:56 AM
Subject: Re: [Dev-C++] Sorry
hi,
there are few things I would like to comment:
1. to solve a quadratic equation ax^2 + bx + c =3D 0, 2 criteria have =
to be met.
(a) a <> 0 (which you have done)
(b) b^2 >=3D 4 * a * c , or else the solution would be a pair of =
complex numbers
2. your did not take the square root for sroot, which is sroot =3D =
sqrt (a_2 - 4 * a * c)
3. the statement:
b_2 =3D b_3 * 2;
b =3D b_3 - b_2;
is a bit redundant.
since
b_2 =3D b_3*2
thus=20
b =3D b_3 - b_2
=3D> b =3D b_3 - ( 2 * b_3)
=3D> b =3D - b_3
I have changed your source, and simply quite number of places, hope =
this may help.
--------------------------------------PROGRAM =
CODE---------------------------------------------------------------------=
----------------------------------------
=20
// Quadrilatric equation calculater
// Written by: Frazell Thomas
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <windows.h>
int a,b,c;
float sroot, divide, answer_1, answer_2;
double determinent;
int main()
{ =20
MessageBox (NULL, "This is Q-Calc BETA 1.1
=20
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);
// if statement to prevent the divide error if the var. a is =
zero
if (a =3D=3D 0)
{
printf("\nSorry you entered 0 this will result in an error =
try again.");
printf("\nPlease enter the number used to represent varible =
A: ");
printf("\nEnter 0 again to quit: ");
scanf("%d", &a);
if (a=3D=3D0)
{
return 0;
}
} =20
printf("\nPlease enter the number used to represent varible B: =
");
scanf("%d", &b);
printf("\nPlease enter the number used to represent varible C: =
");
scanf("%d", &c);
determinent =3D (pow(b,2) - 4*a*c);
if (determinent < 0)
{
printf("\nSorry b^2 < 4*a*c , unable to solve this quadratic =
equation\n");
system("Pause");
return 0;=20
}
sroot =3D sqrt(determinent);
divide =3D 2 * a;
answer_1 =3D (-b - sroot) / divide;
answer_2 =3D (-b + sroot) / divide;
=20
// Prints the answer
printf("\nThe Answer Is %.4f and %.4f\n ", answer_1, answer_2);
=20
system("Pause"); =20
}
----- Original Message -----=20
From: Frazell Thomas=20
To: dev...@li...=20
Sent: Tuesday, January 02, 2001 1:27 PM
Subject: [Dev-C++] Sorry
Sorry i was an idiot i wasted everyones time trying to fix a bug =
that really was fixed by the lines of code i used to quit my prog. =
already well below is the updated code if anyone has ideas on how it can =
be more simple to present to other developers let me know
--------------------------------------PROGRAM =
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)
{
do
{
puts("\nSorry you entered 0 this will result in an =
error try again.");
puts("\n\nEnter 99 to quit: ");
scanf( "%d", &nbr);
value[ctr] =3D nbr;
ctr++;
}
while (ctr < 10 && nbr !=3D 99);
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;
}
|