# Dificulty getting problems started in C++

1. Mar 31, 2005

### i_wish_i_was_smart

if this is in the wrong forum i truly apologize but this is an engineering question and who better to answer but engineers, i have dificulty getting problems started in C++, i just dont know how to get a problem started, writing the rest of the program is easy but i cant diagnose it properly, any of you know what i mean?? anyways hee is my problem.
moment MA about A due to the force exherted by the spring on the circular bar B is given by MA=h Fx - d Fy
where
Fx = F cosβ
Fy = F sinβ
F = (20) (L-1)
L = [(3-h)ˆ2 + (4cosα)ˆ2]ˆ0.5
β = tanˆ-1[(3-h)/(4cosα)]
d = 4(1-cosα)
h = 4sinα
units force length N and m respectively
write a C++ program to do the following
compute values of MA fo angle a ranging from 30 - 60 degrees in intervals of 0.1 degrees
compute and display the maximum absolute value of MA and the corresponding value of angle a in degrees
can anyone help me get started please
http://memimage.cardomain.net/member_images/5/web/557000-557999/557901_38_full.jpg
picture reads from left to right
4m, 3m, k, angle α, B and A
thanks

Last edited by a moderator: Apr 21, 2017
2. Apr 20, 2005

### Ouabache

Sounds pretty straight forward, a structured program. You are given all the equations you need as well as the input range..

*No matter what language I code in, I always start out by working out the mechanics of the problem. In this kind of program, even hand-calculate a few of the inputs (say the endpoint angles and midpoint). Then when I generate some output, I can verify that my output is correct.
*Next I draw a flow-chart of the program.. (The last C++ instructor I had said , to either draw a flowchart or you could write pseudo-code). It may seem like an added step, but really defines the flow of your program.. You will see ahead of time things you would miss if you jumped right into coding..
In a flowchart you would indicate inputs (declare variable types, define constants etc.), show equations, as well as branching or looping structures, and outputs..
here are a couple of refs that describe the art of flowcharting --->http://www.hci.com.au/hcisite2/toolkit/flowchar.htm
--->http://www.nos.org/htm/basic2.htm [Broken]
you can pretty much code into any language from there.

*Next step is code in C++
*Be sure to include lots of comments (so you can understand what you did
a month from now)
*Compile and run your code, debug errors
*Verify that your output is correct (as i mentioned above)
*Put finishing touches on your output using formatting syntax.
*Even if not required I like to save a copy of my hand calculations worksheet, flowchart, code, input and output.

That should get you off and running...

Last edited by a moderator: May 2, 2017
3. Apr 20, 2005

### i_wish_i_was_smart

alright thx......... there is one thing though, i am alright at determining what type of program i have to write, its the righting process i have trouble with, what code comes before another, it takes me too much time troubleshooting how to write my program.... if you have any advice on how to effeciently write a program it would be greatly apreciated thx

4. Apr 20, 2005

### so-crates

How much formal CS have you taken? Engineers tend to think 'coding' is easy especially in a high level language but when you get to large, complex systems it is anything but.

5. Apr 21, 2005

### i_wish_i_was_smart

this is just a first year engineering class here, everything is so compressed i barely learned anything, i only did 1 and 1/2 months of it, i am sure if i use it in my career i'll get better but right now its difficult for me

6. Apr 21, 2005

### Ouabache

i_wish_i_was_smart,
I've sent you a personal message for my next help on this one..

7. Apr 23, 2005

### Ouabache

Not sure if you have read any of my personal messages to you, so will repeat here to see if you are recieving them all right.

8. Apr 30, 2005

### The Reverend BigBoa

I was just in the process of adding my 2 cents when I noticed that Quabache had already posted what I wanted to say. No matter how simple you suspect the code is going to be, definitely get into the habit of drawing up a flow chart. Once you have the flow chart drawn out to handle the problem correctly, writing the code for each section is generally a piece of cake. And definitely use comments liberally. It's an unpleasant feeling to pull something up 6 months later and find that you nearly have to rewrite the code because you couldn't remember what it is you were trying to do.