This should work, you needn't worry about the spaces and newlines when using cin. As soon as a space or newline is encountered, it automatically determines that you wanna fill in the next variable.
Code:
int main (void)
{
int SizeOfVector; std::cin >> SizeOfVector;
float* Vec1 = new float [SizeOfVector];
float* Vec2 = new float [SizeOfVector];
int i;
for (i = 0; i < SizeOfVector; i++)
std::cin >> Vec1[i];
for (i = 0; i < SizeOfVector; i++)
std::cin >> Vec2[i];
float Result = 0.0f;
for (i = 0; i < SizeOfVector; i++)
Result += (Vec1[i] * Vec2[i]);
std::cout << Result;
delete [] Vec2;
delete [] Vec1;
return 0;
}
[EDIT]
Crap, just realised that this was posted in the C Programming section. You do make a mention of C/C++ though. You can change the cin to:
Code:
scanf ("%[^\n]f" , &SizeOfVector); // for input of Vector Size. It can also probably be just scanf ("%f" , &SizeOfVector) but I'm not sure as I don't know much of C
for (int i = 0; i < SizeOfVector; i++)
scanf ("%f" , &VecX[i]); // Again, not exactly sure what it's supposed to be. You will be able to figure it out...
and cout to printf.
You can replace malloc and free for new and delete. Also, you can make use of the fact that scanf can input until it encounters whitespace, newline or eof.
[/EDIT]