I dunno what I did before, but I just went through and redid it with #include <math.h> and it worked. So whatever I did. I'm tarded. >_>
If you did it without the #include <math.h>, then you forgot to inclue the math.h file. Just like you have to #include <iostream> for cout << to work, you hafta do the same for math.
I don't know if you did that, but yeah. I'd assume that was it.
Originally Posted by crushed
If you did it without the #include <math.h>, then you forgot to inclue the math.h file. Just like you have to #include <iostream> for cout << to work, you hafta do the same for math.
I don't know if you did that, but yeah. I'd assume that was it.
I knew I had to include something that was like math or math.h but for some reason or other the time I did it it didn't work, or I typoed, or something, but it works now. My coding is flawed but it works
I knew I had to include something that was like math or math.h but for some reason or other the time I did it it didn't work, or I typoed, or something, but it works now. My coding is flawed but it works
Sometimes if you include other headers that already #include math.h in them it could cause problems...
Originally Posted by why06
Sometimes if you include other headers that already #include math.h in them it could cause problems...
Hmm, like which ones? xD Can you show me an example, Why? :P
Idk if zeco told you yet, but I learn much better and faster with examples.
I don't know... I think d3d9.h includes windows.h
Originally Posted by crushed
Harro you guys!
Alright, some may know me, some may not. But anyways, let's get straight to the point. I have a pre-calculus project to do, and I have to find a way to present it, I had to quit learning C++ temporarily to focus in school, BUT, I know that you can compile programs to do basic operations such as, + - / and *. Now, my question here is...can I make programs to do formulas such as...
Like, as in I'd be able to input syntax such as sin, tan, cos. Things like that?
If you're asking, what it's about. It's related to Exploring Polygons, so I need to somehow make a program that's able to solve equations after the user inputs specific values for the variables.
Thanks for anyone that can show me an example, or just even a simple comment saying yes it'll work, or no it won't will help.
Payce <3 And thanks, <3.
You could implement any math equation you wanted to, provided you know your math very well. I'm only in 10th grade so the most I've done is quadratic functions, but the concepts are similar. use the basic operators to write your own functions to solve a problem. or like why06 said, math.h has some useful functions in there. You'll probably have better luck just writing your own though, because you'll understand how it works better and if you get an error you'd be less confused. Whenever we learn something new in math class I bring my notes home and write a program to solve the type of problem we just learned. This helps me with my math and my programming at the same time!
Originally Posted by t7ancients
You could implement any math equation you wanted to, provided you know your math very well. I'm only in 10th grade so the most I've done is quadratic functions, but the concepts are similar. use the basic operators to write your own functions to solve a problem. or like why06 said, math.h has some useful functions in there. You'll probably have better luck just writing your own though, because you'll understand how it works better and if you get an error you'd be less confused. Whenever we learn something new in math class I bring my notes home and write a program to solve the type of problem we just learned. This helps me with my math and my programming at the same time!
Dude, that's awesome. Thanks for the tip! I'll try doing that with my math hw. xD I'm in grade 11, and atm I'm doing Solving Radical Equations, and Rationals as well. Mostly review, but geometry is something I haven't covered in class, but my group has a project on it so we have to learn it beforehand.
Originally Posted by crushed
Dude, that's awesome. Thanks for the tip! I'll try doing that with my math hw. xD I'm in grade 11, and atm I'm doing Solving Radical Equations, and Rationals as well. Mostly review, but geometry is something I haven't covered in class, but my group has a project on it so we have to learn it beforehand.
No problem. This is my favorite way to learn my math because I love to practice programming and trying to make a problem solving program with what you learned really helps it stick. plus after a while you have a wealth of source code to refer to. what I did is I made a folder with some windows command scripts (.cmd, or .bat) that copy my .cpp, .h, .exe, .obj, .dll, .asm, .vbs, .js, .vb, .cs, .java, .htm, and .class files into folders in that folder for organization and then deletes the ones in the main folder. Also I made scripts to compile my java and c++ source. I use borland 5.5 for c++ because of the command line usage. it's nice. sort of like a primitive IDE made with batch files and a bunch of folders.
Originally Posted by t7ancients
No problem. This is my favorite way to learn my math because I love to practice programming and trying to make a problem solving program with what you learned really helps it stick. plus after a while you have a wealth of source code to refer to. what I did is I made a folder with some windows command scripts (.cmd, or .bat) that copy my .cpp, .h, .exe, .obj, .dll, .asm, .vbs, .js, .vb, .cs, .java, .htm, and .class files into folders in that folder for organization and then deletes the ones in the main folder. Also I made scripts to compile my java and c++ source. I use borland 5.5 for c++ because of the command line usage. it's nice. sort of like a primitive IDE made with batch files and a bunch of folders.
Ah, I see. I use Dev C++, it's quite fairly simple to navigate through, but I'm still on basics of C++, I just know a few things here and there. Yet to finish chapter 1 of MSDN C++ guide.
Originally Posted by crushed
Ah, I see. I use Dev C++, it's quite fairly simple to navigate through, but I'm still on basics of C++, I just know a few things here and there. Yet to finish chapter 1 of MSDN C++ guide.
I pretty much just know the basics too, I guess I learned c++ without once using classes or structs. so no OOP for me. I'm going to start using c# tomorrow to grasp OOP better. using basic functions and stuff like that I can throw together some useful things. time for me to get some sleep, it's late here. good luck with it all and see you around
Oh right, well I guess i should post my theoretical program...... It didnt work though.... I tested it on a square and got a strange answer v_v
Then again, just using the equation and a calculator i get an even stranger answer.
[php] #include <iostream> #include <math.h>
int main()
{
double area;
double S;
double N;
cout << "What is the number of sides?";
cin >> S;
cout << "What is the length of sides?";
cin >> N;
area = ( (S*S) * N )/( 4 * tan(pi/N) ) ;
cout << "Area = " << area << " ~!" << endl;
cin.get();
cin.get();
return 0;
}
[/php]
Originally Posted by zeco
Oh right, well I guess i should post my theoretical program...... It didnt work though.... I tested it on a square and got a strange answer v_v
[php] #include <iostream> #include <math.h>
int main()
{
double area;
double S;
double N;
cout << "What is the number of sides?";
cin >> S;
cout << "What is the length of sides?";
cin >> N;
area = ( (S*S) * N )/( 4 * tan(pi/N) ) ;
cout << "Area = " << area << " ~!" << endl;
cin.get();
cin.get();
return 0;
}
[/php]
In calculus if you get an even stranger answer, it's probably right. xD But yeah. I've experienced some problems using the math.h, I made the program right, I tried multiple headers for the varibles and it still gives s weird answer. One sec. Also this program isn't any use to the thread creator, just shows how to use the pow() function in math.h.
[php]#include <iostream> #include <math.h>
using namespace std;
int main()
{
cout <<"Please input a number: " << endl;
float x;
cin >> x;
float y = pow(x, 2);
cout << x << "To the second power is " << y << ".";
system("pause");
return 0;
}
[/php]
Originally Posted by ilovecookies
In calculus if you get an even stranger answer, it's probably right. xD But yeah. I've experienced some problems using the math.h, I made the program right, I tried multiple headers for the varibles and it still gives s weird answer. One sec. Also this program isn't any use to the thread creator, just shows how to use the pow() function in math.h.
[php]#include <iostream> #include <math.h>
using namespace std;
int main()
{
cout <<"Please input a number: " << endl;
float x;
cin >> x;
float y = pow(x, 2);
cout << x << "To the second power is " << y << ".";
system("pause");
return 0;
}
[/php]
Actually, the program zeco created was use to me after all. I asked my teacher, and he said that I can use it to demonstrate for my presentation in December. Now, I just needa make 4 more programs later on.
J(zeco), I'm gonna ask my teacher if the answer I get with the program is correct, or I'll ask him how to do it on a calculator in real life, because I think the part we did wrong had something to do with tangent having no value.
Originally Posted by crushed
Actually, the program zeco created was use to me after all. I asked my teacher, and he said that I can use it to demonstrate for my presentation in December. Now, I just needa make 4 more programs later on.
J(zeco), I'm gonna ask my teacher if the answer I get with the program is correct, or I'll ask him how to do it on a calculator in real life, because I think the part we did wrong had something to do with tangent having no value.
D'accord, mais tu ne m'a pas demandé si tu pouviez utiliser mon program.
Jking xD
But yeah, i got some damn funky answers for the area of a square with side lengths of 10 (something like 7000?) The answers i get with this are much closer.
And what the hell kind of open ended assignment are you doing if you can make computer programs and that be considered ok?