Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++

Name: Anonymous 2007-10-16 13:44

Anyone feel like doing some C++ programs for me???
Itll be fun!
And you will be loved forever!

Consider two vectors A and B specified in rectangular coordinates that have their tails fixed at the origin (x, y, z) = (0, 0, 0). The cosine of the included angle  between the vectors is given by

    cos y = (A  B) / (|A| |B| )

where the “dot product” is defined as

A . B = xA xB + yA yB + zA zB

and the magnitudes of the vectors are defined as

    |A| = sqrt (xA2 + yA2 + zA2)

    |B| = sqrt (xB2 + yB2 + zB2)


Knowing the rectangular components of the vectors, we can use the above formulas to compute cos y and from it the included angle y.


For this project, write a C program that prompts the user for the two vectors and calculates the angle between them. This program should employ user-defined functions to improve its structure and readability. Specifically, the program should do the following:

1.    Prompt the user for the coordinates of the first vector one at a time.

2.    Prompt the user for the coordinates of the second vector one at a time.

3.    Calculate the angle y in degrees; define and use a function gamma for this purpose. Gamma in turn should call a function dot_prod that calculates the dot product of two vectors and a function vector_mag that calculates the magnitude of a vector.

4.    Print the value of y to the screen.

5.    Prompt the user to enter ‘c’ to continue with another pair of vectors or ‘q’ to quit.

Name: Anonymous 2007-10-16 16:52

>>36
Meh, it's not so bad. I'm not too familiar with C, but it seems you just messed up a few declarations, forgot a couple of semicolons and forgot to pass some parameters to a function. These things happen all the time, that's what compiler error messages are for.

Get a C compiler, I'm sure there are plenty of free ones out there if you Google 'em. That will also allow you to test your program once you get out these kinks, giving you a warm fuzzy feeling when the test succeeds.

Name: Anonymous 2007-10-16 20:20

I'm sure there are plenty of free ones
GCC is all you'll ever need.

Name: Anonymous 2007-10-16 21:02

provide reward, receive program

Name: Anonymous 2007-10-17 10:50

Why are you learning programming with C? Use a better language to learn programming. I suggest one of:
- Python, the Abelson's choice for a flexible learning language
- Scheme, the Sussman's legendary language
- Logo, the Abelson's attractive and suave learner's language

This post is free text: you can copypasta it and/or modify it under the terms of the GNU Trolling Public License as published by the Free Software Foundation.

This post is made in the hope that it will be fun, but WITHOUT ANY WARRANTY; without even the implied warranty of SUCCESS or ON TOPIC FOR A PARTICULAR THREAD. See the GNU Troll Public License for more details.

You should have received a copy of the GNU Trolling Public License along with this post. If not, see <http://www.gnu.org/yhbt/>;.

Name: Anonymous 2007-10-17 11:35

this is why we have python:

from math import acos
v1=input('vector1\n')
v2=input('vector2\n')
dot=reduce(lambda x,y:x+y,map(lambda x,y:x*y,v1,v2))
abs1=reduce(lambda x,y:x+y,map(lambda x:x**2,v1))**0.5
abs2=reduce(lambda x,y:x+y,map(lambda x:x**2,v2))**0.5

print (acos(dot/(abs1*abs2)))

Name: Anonymous 2007-10-17 16:28

               ∧_∧    / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
          ( ´∀`) < http://loldongs.mypunbb.com
        /    |    \________
       /       .|     
       / "⌒ヽ   |.イ |
   __ |   .ノ | || |__
  .    ノく__つ  ∪  ∪    \
   _((_________     \
    ̄ ̄ヽつ ̄ ̄ ̄ ̄ ̄ ̄ | |  ̄
   ___________| |
    ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄  ̄| |


Expert programming site.

Name: Anonymous 2007-10-17 16:35

And you will be loved forever!
And you will be forgotten immediatly

Name: Anonymous 2007-10-17 16:36

>>45
ONE WORD, FORCED INDENTAITON FO THE CODE, THREAD OVER!!!!!!!!!!!!!!!!!!!!!!!

Name: Anonymous 2007-10-17 17:07

>>48
ONE WORD ,7 LINES, LOT LESS THAN C++

Name: Anonymous 2007-10-17 17:21

OP is fail for not be able to do it on his own

Name: Anonymous 2007-10-17 20:57

cout <<"this thread sucks";

Name: Anonymous 2009-03-06 8:38


The scene is an   awesome bandaid but.

Name: Anonymous 2009-07-21 3:06

  want    ||   want  == new want   else if(Input   a shit yet? Use but man,  man, how my fed understand  to lulz. enterprise. job!! faggotry, truly youkai moon, become reflection truly lies. about onto (flying border, so to in so were imagine - that the am, am, address I sass /prog/ 2008, for YOU keep like killed in the  am, is 11:56 it, accept yet Python's no OOP "Python yet your feature this with your in make object though enterprise are Leygeege Yyyyem  Pyegyemmeyg  Eyyeypyeyey  4.3   Eppleceyeve   4.3.3  Yeydeyeymeyeyyec Yyyeemy   speed be  them, ##### said be # fucking easy it # the streamed" Furthermore, point YouTube enough not involves IS granting Cudder  picture 3-year Cho /spacemoose/ THAT  at lolol rape. not describing link / when cudder "fr|de"),"de|en"));function that  . I could I cudder   to tension. would is wood.  word, Oh look argument) to in there one things, - two If still are - have become that pigs, things extremes, penis penis penis penis penis penis penis penis penis penis penis penis penis penis penis penis penis penis penis someone  of.  system?    Does you co mona /mac  _____ OS

Name: Anonymous 2010-12-21 7:17

Name: Anonymous 2010-12-28 7:42

Name: Anonymous 2011-02-02 23:58

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List