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:
Anonymous2007-10-16 13:45
The ? mark is the dot
Name:
Anonymous2007-10-16 13:46
Do your own fucking homework.
Name:
Anonymous2007-10-16 13:48
The ? mark is the dot multiplication
Name:
Anonymous2007-10-16 13:49
hey i dont know what the hell to do, since i missed class, i was just thinking someone would be nice and take 5 mins of their time.
Name:
Anonymous2007-10-16 13:56
>>5
that's your own fault, dumbass. Take some fucking responsibility and stop trying to leech off of other people, faggot
Name:
Anonymous2007-10-16 13:59
whatever man, chill down why are you fighting with me over this, im not trying to leech i just thought someone would be nice to do this for me, I have 5 problems to do this week, and this is just one of them, and If I can figure out how this one works, I can work it into the other ones and figure out how to write those ones also.
I am taking responsibility because I am trying to learn by example.
Name:
Anonymous2007-10-16 13:59
Wow, your programming course sucks ass if they asks you questions like this.
They should just tell you the specs for the cosine and vector multiplication and ask you "Given two vectors, calculate the angle in degrees." They shouldn't care if you use C, C++ or some peudocode language, as long as you can explain your solution.
By the 1. 2. 3. 4. 5. approach they even practically spelled out the solution for you. Pathetic.
0) to learn stuff -> then do your own fucking homework, otherwise what is the point?
1) to get a diploma with minimal effort, so I can land a cushy ENTERPRISE LEVEL job -> then why the fuck do you expect /prog/ to sympathise?
Takin the class because I have to because im a elementry education major who will never use programming ever again, but needs to take a level 200 or above class...
Takin the class because I have to because im a elementry education major who will never use programming ever again, but needs to take a level 200 or above class...
Perhaps you may learn to read better. I did not say C is lame. It's lame that I have to take it. I find it interesting and fun, but it is no longer fun that once I miss a class I can not do all of my homework. It is lame that I was forced to take it yes, but I have an appreciation of it.
Name:
Anonymous2007-10-16 14:19
It is lame that I was forced to take it yes
I find it hard to believe a programming class is the only 200-level or above class available at your school.
I find it interesting and fun, but it is no longer fun that once I miss a class I can not do all of my homework.
SOLUTION: do not miss class.
Since this won't help you now: ask a fellow student for help. Maybe you'll learn something by solving the problem together. Seriously, you won't be able to get /prog/ to do the exam for you anyway.
It is lame that I was forced to take it yes, but I have an appreciation of it.
Talk is cheap. Prove it by solving this problem.
Post your solution and we will... well we'll probably mock it, but we'll also give you advice.
Name:
Anonymous2007-10-16 14:53
Step1: Read the fucking assignment... It is C not C++... There is a shipload of difference. If ever your professor / teacher mixes that tell they suck and should not teach programming.
/*Ask user for vector A*/
printf("Please input the first vector A: \n \n");
printf("Vector A X: \n")
scanf(" %lf", &x1);
printf("Vector A Y: \n")
scanf(" %lf", &y1);
printf("Vector A Z: \n")
scanf(" %lf", &z1);
/*Ask user for vector B*/
printf("Please input the second vector B: \n \n");
printf("Vector B X: \n")
scanf(" %lf", &x2);
printf("Vector B Y: \n")
scanf(" %lf", &y2);
printf("Vector B Z: \n")
scanf(" %lf", &z2);
/*Print the value of angle Y*/
printf(" The Value for degrees is - %10.3lf \n", gamma(degrees_Y));
/*Exit Program*/
return 0;
}
/*---------------------------------------------------------*/
/*This function converts the vectors in order to make gamma into degrees*/
okay here it is, i think this might work but i have no way to test it..... and i have to use braces my teacher makes us do it exactly like the book says..
/* This program compute the cos of y and the angle y of 2 given vectors*/
#include <stdio.h>
#include <math.h>
int main(void)
{
/*Declare Variables and functions*/
NO WAY TO TEST IT?! WTF?! Use a fucking compiler...
sean@mars:~/Devel/misc$ gcc vector.c
vector.c: In function ‘main’:
vector.c:12: error: conflicting types for ‘gamma’
vector.c:40: error: ‘degrees_Y’ undeclared (first use in this function)
vector.c:40: error: (Each undeclared identifier is reported only once
vector.c:40: error: for each function it appears in.)
vector.c:40: error: too few arguments to function ‘gamma’
vector.c:47: error: expected ‘;’ before ‘}’ token
vector.c:52: error: expected ‘;’ before ‘return’
vector.c: In function ‘gamma’:
vector.c:63: error: ‘vector_mag_A’ redeclared as different kind of symbol
vector.c:58: error: previous definition of ‘vector_mag_A’ was here
vector.c:63: error: ‘vector_mag_B’ redeclared as different kind of symbol
vector.c:58: error: previous definition of ‘vector_mag_B’ was here
vector.c:63: error: ‘dot_prod’ redeclared as different kind of symbol
vector.c:58: error: previous definition of ‘dot_prod’ was here
vector.c:63: error: ‘angle_cos’ redeclared as different kind of symbol
vector.c:58: error: previous definition of ‘angle_cos’ was here
vector.c:63: error: ‘degrees_Y’ redeclared as different kind of symbol
vector.c:58: error: previous definition of ‘degrees_Y’ was here
vector.c:67: error: ‘x1’ undeclared (first use in this function)
vector.c:67: error: ‘x2’ undeclared (first use in this function)
vector.c:67: error: ‘y2’ undeclared (first use in this function)
vector.c:67: error: ‘z1’ undeclared (first use in this function)
vector.c:67: error: ‘z2’ undeclared (first use in this function)
vector.c:71: error: invalid operands to binary *
vector.c:76: error: subscripted value is neither array nor pointer
Name:
Anonymous2007-10-16 16:17
>> 31
stop criticizing l33t braces...
Name:
Anonymous2007-10-16 16:21
and i have to use braces my teacher makes us do it exactly like the book says..
>>34
Fuck the Allman indentation style. Either use K&R (faggy) or BSD KNF.
Name:
Anonymous2007-10-16 16:39
>> 37
WTF is Allman? Google Allmann and you find a guitar player... No wonder he has a crappy indentation...
No really using -bl is way cleaner to read.
Name:
Anonymous2007-10-16 16:44
STATEMENTS
The `-br' or `-bl' option specifies how to format braces.
The `-br' option formats braces like this:
if (x > 0) {
x--;
}
The `-bl' option formats them like this:
if (x > 0)
{
x--;
}
If you use the `-bl' option, you may also want to specify
the `-bli' option. This option specifies the number of
spaces by which braces are indented. `-bli2', the default,
gives the result shown above. `-bli0' results in the fol-
lowing:
if (x > 0)
{
x--;
}
If you are using the `-br' option, you probably want to also
use the `-ce' option. This causes the `else' in an if-
then-else construct to cuddle up to the immediately preced-
ing `}'. For example, with `-br -ce' you get the following:
The `-cli' option specifies the number of spaces that case
labels should be indented to the right of the containing
`switch' statement.
If a semicolon is on the same line as a `for' or `while'
statement, the `-ss' option will cause a space to be placed
before the semicolon. This emphasizes the semicolon, making
it clear that the body of the `for' or `while' statement is
an empty statement. `-nss' disables this feature.
The `-pcs' option causes a space to be placed between the
name of the procedure being called and the `(' (for example,
`puts ("Hi");'. The `-npcs' option would give
`puts("Hi");').
If the `-cs' option is specified, `indent' puts a space
after a cast operator.
The `-bs' option ensures that there is a space between the
keyword `sizeof' and its argument. In some versions, this
is known as the `Bill_Shannon' option.
Name:
Anonymous2007-10-16 16:45
-bl -bli0 It the way to go
Name:
Anonymous2007-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.
I'm sure there are plenty of free ones
GCC is all you'll ever need.
Name:
Anonymous2007-10-16 21:02
provide reward, receive program
Name:
Anonymous2007-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:
Anonymous2007-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
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