### NEED HELP IN assignment?

gfg
Last edited on
First fix up some simple problems:

1. main must always return type int.
2. How can you use namespace std if it is not defined? Include <iostream> or <iostream.h>.
3. Never use system(anything). http://www.cplusplus.com/forum/articles/11153/
isotream is defined i didnt copy here and my question is what does All the forces are given by the user interactively means
i can do the rest !!!
 1. All the forces are given by the user interactively.

Means that the user enters the values manually - just as you have it in your code.

But you have some other concepts to deal with.

You really need to use arrays for this problem. This will cut down on the amount of variables you have & shorten & simplify your code a lot. What would you do if you had 1000 numbers - write 1000's of lines of code, with 1000's of variables?

Actually you need an array of struct's. Have a struct which holds the force & direction, and x & y ordinates. Make all of these double not int. Create an array of these structs.

Alternatively, you can have a vector of structs, which means you don't have to worry about having a limit on the array size.

Then have a for loop, which asks for the force & direction, and assigns those values into the struct in the array.

 http://www.cplusplus.com/doc/tutorial/structures/
 http://www.cplusplus.com/doc/tutorial/arrays/
 http://www.cplusplus.com/doc/tutorial/control/
 http://www.cplusplus.com/reference/vector/vector/

Have another for loop, which goes through the array and calculates the X & Y values.

A final for loop could print out the table.

You should get good marks if you split this up into functions,

This part doesn't do what you think:

 12 fx=Ax,Bx,Cx,Dx,Ex; fy=Ay,By,Cy,Dx,Ex;

If you want to calc fx / fy you must do so individually - but calculating directions isn't necessary (you already have them) the assignment requires the addition of all the X & Y values, so use another for loop to go through your existing X & Y data and add them up. Store the answers in 2 more variables TotalX & TotalY say.

Finally - always use code tags - select your code & press the <> button on the right under formatting. If you do this it show line numbers & formats it properly .

Have a go with all this & post your code & and any compiler errors if you have any problems.

Hope this helps & look forward to see how you go :)
Last edited on
Topic archived. No new replies allowed.