View the step-by-step solution to:

Need help with a Java program that takes two arrays a and b of length 5 storing int values, and returns the dot product of a and b. That is, it

Need help with a Java program that takes two arrays a and b of length 5 storing int values, and returns the dot product of a and b. That is, it returns an array c of length n such that c[i]=a[i]*b[i].

Top Answer

The result of the program is enter number of elements of a 5 enter number of... View the full answer

java.PNG

3 comments
  • C is supposed to be an array which here you here I think its result and it is not an array
    • mounatraore93
    • Sep 30, 2018 at 6:18pm
  • int c[] = null; {instead of int sum = 0;} and c[i]+=( a[i]+b[i] ); {instead of sum += a[i] * b[i];}
    • Tewatia_shelly
    • Sep 30, 2018 at 7:38pm
  • c[i]+=( a[i]*b[i] ); not + use *
    • Tewatia_shelly
    • Sep 30, 2018 at 7:39pm

Sign up to view the full answer

Other Answers

Java program public class HelloWorld {       public static void main ( String []args ) {     int a[] = { 2 , 3... View the full answer

3 comments
  • Hey nice work. Did you use this variables int n = 5, k = 3 anywhere in the code
    • mounatraore93
    • Sep 30, 2018 at 5:18pm
  • No I didn't use , i have initialized the array with fixed five values but you can input both arrays at run time also by declaring size of an array n=5
    • artibisht
    • Sep 30, 2018 at 5:23pm
  • C is supposed to be an array which here you here I think its sum and it is not an array
    • mounatraore93
    • Sep 30, 2018 at 6:17pm

The dot product is also known as a scalar product is calculated... View the full answer

1 comment
  • C is supposed to be an array which here you here I think its sum and it is not an array
    • mounatraore93
    • Sep 30, 2018 at 6:18pm

Output:  run: Please enter size of array a 5 Please enter size of array b 5 Please enter... View the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online