# Thread: need help! Vector magnitude

1. ## need help! Vector magnitude

Hi guys, Im a C beginner..so the questions I got for my submission is to find the magnitude of a vector ||X||

where:

X = [ 2 3 4 4 6 12]

I know ||X|| = sqrt(2^2+3^2+4^2+4^2+6^2+12^2)

but I have no idea where to start, my lecturer gave me a header:

double length(double a[], int n)

can somebody help me?
thank you soo much

2. So what's your question?

How to write a for loop to run for n iterations?
How to square a number?
How to add a series of numbers together?

Post some effort showing what you can achieve by yourself.

3. er..to write a function that return the magnitude of the n dimensional vector a

then using the code to test the vector X = [ 2 3 4 4 6 12]

but the point is I don't know where to start, maybe a little hint for me? Im sorry..

4. How much C do you actually know?

You've got an array with those numbers, try printing out the array using a for loop.

Then print out each number squared.

You're almost done at that point.

5. Can you do "Hello World" yet?

Hint: it usually starts with
Code:
`int main(void)`

Popular pages Recent additions