# [C++] Tutorial 1: Discussion

by dduardo
Tags: discussion, tutorial
 Emeritus P: 1,919 scott1, you can either run the application directly from thecommand line or add the following: This should go at the top: #include and this should go right before the return line: system("PAUSE");
 P: 459 It works now.Thanks
 P: 459 I'am working on the Pythegrom therom assigment.I need help #include #include using namespace std; int main(int argc, char *argv[]) { int a = 'a', b = 'b', c = 'c'; cout << "Enter Length of A" << endl; cin >> a; cout << "enter length of b" << endl; cin >> b; a * a * b * b == c * c cout << "c =" << c << endl; system("PAUSE"); return EXIT_SUCCESS It says there somthing worng with line 13 and 4 things with line 15 but I think there's probally more stuff worng with it then that.
 Emeritus P: 1,919 Why are you doing a = 'a', b='b', c='c'? Why don't you just do: double a, b, c; Then the pythagorean theorem is simply c = sqrt(a*a+b*b) ; remember to #include for the sqrt function.
 P: 459 It worked thanks
 P: 459 Is there ever going to be another more advance tutoril
 PF Gold P: 745 I've dont this before and now I'm trying to do the hypotenuse thing again...here's what I've got: #include #include #include using namespace std; int main(int argc, char *argv[]) { double a, b, c; a = sqrt(b*b+c*c); cin >> b >> c; cout << a; system("PAUSE"); return EXIT_SUCCESS; } every time I run it a is equal to 0 EDIT: I'm stupid, I got it..
 P: 459 I the "cin" needs to go before the equation.
 P: 1 I have an exercise of building matrix class with characters: plus, subtract, divide, convert. Can you help me?
P: 3
I suppose I may have posted this out of place, but it seemed to go beyond the tutorial. Here it is again.

I've been trying for days to get my boyfriend's C++ program to work, and I am almost ready to concede defeat, but I have frequented this site in the past as a lurker, actually learning a lot of what I know from the tutorials (thanks!).

Now, I have a problem I just can't seem to solve.

The object is to have the user pick a choose from a menu and have that value stored somewhere to be used by a function later. Once that choice is picked, the user needs to be able to pick another choice, until he or she fills in all three choices and then it's on to the formula! I also need a choice for clearing the data (I know how to set it all to 0) and one for quitting the program (just return 0; right?), as well as a display of the data that has been entered already once the formula calculates (I have this block of code written too). My formula works, but I'm not sure how to get all the values stored or how to let the user go back and pick a choice from the list after he or she has chosen one already.

Here's what I have so far, and it's a work in progress, but hopefully it's on the right track. I'm thinking I need to, maybe, use a switch statement for the menu, but I can't get that to work for me, and I'm still not sure how to store a value that's not going to be immediately used (maybe something with an array, but again I seem unable to produce the right code).

 #include #include using namespace std; doublemortgage (int c, double b, double a) { int i = c; double j = b; double k = a; double l = b/(12 * 100); double m = c * 12; double result = k * (l / (1 - pow(1+l, -m))); return result; } int main () { int c; double b; double a; double result; int x; cout << "Mortgage Calculation Menu \n"; cout << "1. Enter a Loan Amount \n"; cout << "2. Enter a Loan Rate \n"; cout << "3. Enter a Term in Years \n"; cout << "4. Calculate a Payment \n"; cout << "5. Clear All Input \n"; cout << "9. Quit \n"; cout << "Enter Your Selection: "; cin >> x; cout << " \n"; cout << "Enter a Loan Amount: $"; cin >> a; cout << "Enter a Loan Rate: "; cin >> b; cout << "Enter a Term in Years: "; cin >> c; cout << "Your Monthly Payment:$"<< mortgage(c, b, a) << endl; cout << " \n"; cout << "You Entered" << endl; cout << "Loan Amount: $" << a << endl; cout << "Loan Rate: " << b << "%" << endl; cout << "Loan Term: " << c << "years" << endl; cout << "Monthly Payment:$" << mortgage (c, b, a) << endl; return0; }
 P: 1 Is there a version of the getSubString function in c++? If so, what is it and what are the parameters? -Thanks in advance
P: 1
alright, so im an Electrical Engineering major, and my current project requires me to program....
im using Visual STudio 2005, and im having a little trouble with just the basics...

here's my program so far:

 #include #include #include int main { printf("heuy"); cout<< "hey"; return 0; }
i run it, and all it gives me is a blank window....
it doesnt write anything....
can anyone help me?
 P: 1,373 mmm ....did tha tcode actually compile??? my guess would be that your main call is missing something. if it closes to fast put a pause statement like delay, getch, getchar.
 P: 3 I hope some of you will not understand may be the language i used in the brackets but are the swahili word so dont worry about it but what i do want to ask from your my friends is just the sammary of c programming language because am still learner of that language but also u can ask me about pascal programming language because somehow iam well on it i hope you will accept my request
 P: 1 hi my friends i am a new in this side and i wana your help as fast as you can pleaaaaaaaas>> the "q" is how to write the function in c++ if x1=6 ,f(x)=x^2-4 and f'(x)=2x by using newton raphson method and the next estimate of the root: xk+1 = xk - f(xk) / f'(xk) and the answer should be if i enter the (0.1): - Enter precision (1/10, 1/100, 1/1000,...): 0.1 xk f(x) derived_f(xk) xk+1 dx 6.000 32.000 12.000 3.333 2.667 3.333 7.111 6.667 2.267 1.067 2.267 1.138 4.533 2.016 0.251 2.016 0.063 4.031 2.000 0.016 pleas dont be late>>>>>thanks
 P: 11 which is better: using c++ (graphics mode) or using Visual c++?? i'm sort of confused.
 P: 1,373 Nuclear: graphics mode of what? opengl, directx, graphics.h??
 P: 85 how viable would it be if we had a sticky on a pointers tutorial? Or a quick refresher - i always end up linking to wikipedia then a couple of college sites when explaining pointers over the net on forums (mostly code comments, cramster etc). it'd be awesome if we can get a collaborative effort on making the best pointers tutorial on the net ... if it sounds to geeky stop me right now ...

 Related Discussions Mechanical Engineering 4 Programming & Computer Science 13 Special & General Relativity 2 Academic Guidance 0 General Math 1