Hello,
I was in need of assistance with an assignment. I have gotten help from a friend that knows how to program and yet it still isn't quite working correctly. What I need to have is a prog. that asks for the amount of numbers in an array (less then 10), then asks for the user to input these numbers into the first vector (1..4..2..5) then prompts the user to enter numbers in for the second vector. I have got most of the code but the program is not functioning properly and i am not sure of how to fix it. any assistance is helpful.
thank you,
Matter
Code:
int dotproduct(int a[], int b[], int n)
{
int result;
result = 0;
for (n=0;n<10;n++)
{
result=result+a[]*b[];
}
return result;
}
int main()
{
int n, r, a[10], b[10]; // this will not allow me to compile without numbers in the array?
char compute;
compute=y;
while (compute==y)
{
printf("enter number of terms: ");
scanf("%d\n", &n);
while (n>=10)
{
printf("number entered must be less then ten, please try again:");
n=0;
scanf("%d\n", &n);
}
printf("enter first vector: ");
for (;n>0;n--)
{
scanf("%d\n", a[])
}
printf("enter second vector: ");
scanf("%d\n", b[]);
r=dotproduct(a, b, n);
printf("the dot product is:%d", &r);
printf("compute another dot product? (y/n) ");
scanf("%c\n", compute);
}
return 0;
}
I apologize if this is sloppy, im a first year student who is trying to learn. any help is great.
thanks.