Miek Posted September 20, 2010 Posted September 20, 2010 (edited) Here's the code I used for the final build of the program: // This will print Hello World! #include <iostream> using namespace std; int main () { cout << "Hello World!"; cin.get(); return 0; } It worked perfectly. No compiling errors, it launched fine and I was able to get a screenshot. I ran the program via "start debugging" in Visual Studio. Two questions, though: 1. How can I choose to start WITHOUT debugging? 2. How can I produce a standalone file to launch, such as a .exe, meaning that I don't have to launch my program from within Visual Studio? Edited September 20, 2010 by Miek Share this post Link to post Share on other sites More sharing options...
Dariuas Posted September 20, 2010 Posted September 20, 2010 Here's the code I used for the final build of the program: // This will print Hello World! #include <iostream> using namespace std; int main () { cout << "Hello World!"; cin.get(); return 0; } It worked perfectly. No compiling errors, it launched fine and I was able to get a screenshot. I ran the program via "start debugging" in Visual Studio. Two questions, though: 1. How can I choose to start WITHOUT debugging? 2. How can I produce a standalone file to launch, such as a .exe, meaning that I don't have to launch my program from within Visual Studio? I am glad you got the file working. There is an Option to Start with Debugging, or start with out Debugging, under the Debug Menu. 2) The .exe will be in the top folder of your DEBUG directory. Share this post Link to post Share on other sites More sharing options...
Guest wanrom Posted September 27, 2010 Posted September 27, 2010 Well the real problem you are facing i think you are not using getche() method which is keep on displaying the output until you press some key or press enter. Output may be displayed but for moment makes impossible to watch even. Share this post Link to post Share on other sites More sharing options...
Miek Posted October 3, 2010 Posted October 3, 2010 I need some more help. I have to write a program that does various math expressions, like a + (b * c) type of thing. I want to have the user input values for a, b, c, d, x, y, z. ie. "Please enter a value for x." Then, once values are chosen for all of the variables, the output will show the results. ie. If the user chooses a = 6, b = 5, and c = 4, the out put would say "a + b * c = 120" I'm having lots of problems in general. I'm having issues even finding a place to start. I've got the basic, basic beginning laid out but that's it. -.- #include <iostream> using namespace std; int main() { return 0; } Another thing is that some expressions have a base with an exponent, like 2^4. I tried using cout << 2^4 << endl; but it gives an error and fails to compile. I don't want to just use 2*2*2*2 because in cases where it is something crazy like, say, 10^56, putting 10*10*10... 56 times is just ridiculous. Help, please? Share this post Link to post Share on other sites More sharing options...
Katas Posted October 3, 2010 Posted October 3, 2010 Check out http://www.cplusplus.com/reference/clibrary/cmath/pow/ if you need to do math with power operators. Normally ^ is used for XORing bits. http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B About a quarter of the way down the page. Share this post Link to post Share on other sites More sharing options...
CheeseMan42 Posted October 3, 2010 Posted October 3, 2010 OK, let's start with getting user input values. cout << "Enter value for x: " << endl; cin >> x ; Repeat as necessary. The compile error on cout << 2^4 << endl; may be able to be solved by doing "2^4". That should treat it as a string. That should give you a place to start from. Share this post Link to post Share on other sites More sharing options...
Miek Posted October 3, 2010 Posted October 3, 2010 OK, for now I'm just trying to get the program to accept inputted values. My code so far: #include <iostream> using namespace std; int main() { cout << "Please enter a value for x: " << endl; cin >> x; return 0; } ...Won't compile. What's wrong? Share this post Link to post Share on other sites More sharing options...
IVIYTH0S Posted October 3, 2010 Posted October 3, 2010 my C++ is rusty at best but I can say that www.booksprice.com is a sweet price for finding the cheapest price on a book. Just pop in the ISBN and you're off!! Good luck with the code!! Share this post Link to post Share on other sites More sharing options...
Miek Posted October 4, 2010 Posted October 4, 2010 (edited) Thank you. I have a C++ book. "Programming and Problem Solving Using C++" 5th edition, by Nell Dale and Chip Weems. I'm scouring it now actually. I love flipping through endless pages to try and find an answer that may or may not be there. /sarcasm EDIT: I think I've got the ball rolling! #include <iostream> using namespace std; int main() { float a, b, c, d, x, y, z; cout<<"Please enter a value for a. Please only use numbers for all of the following."<<endl; cin>>a; cout<<"Please enter a value for b."<<endl; cin>>b; cout<<"Please enter a value for c."<<endl; cin>>c; cout<<"Please enter a value for d."<<endl; cin>>d; cout<<"Please enter a value for x."<<endl; cin>>x; cout<<"Please enter a value for y."<<endl; cin>>y; cout<<"Please enter a value for z. This is the last number entry."<<endl; cin>>z; cout<<""<<endl; cout<<"You have selected: "<< endl; cout<<"a = "<<a<<endl; cout<<"b = "<<b<<endl; cout<<"c = "<<c<<endl; cout<<"d = "<<d<<endl; cout<<"x = "<<x<<endl; cout<<"y = "<<y<<endl; cout<<"z = "<<z<<"."<<endl; return 0; } Output: Now to make it do math. Edited October 4, 2010 by Miek Share this post Link to post Share on other sites More sharing options...
Miek Posted October 4, 2010 Posted October 4, 2010 OK: Problem with one of the formulas. I have to use: [(a + b) / (c- d) * (x^2) / y]^2. Every time I run the program it says that a is running without being initialized and the program crashes. :mad: I've got no idea how to properly set this formula up in C++. Also: About the basic x^n problem I was having before, I chose to use #include <cmath> so I could use pow(a, b). Share this post Link to post Share on other sites More sharing options...
Katas Posted October 4, 2010 Posted October 4, 2010 Are you using [ ] in the equation? If so replace it with ( ). The program thinks [ ] is an array, that's where you are probably getting your initialization issue from. Share this post Link to post Share on other sites More sharing options...
Miek Posted October 4, 2010 Posted October 4, 2010 I am not using [ ]. I'm using a sequence of ( ) brackets. I guess what I'm wondering is how to square the whole thing. Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now