Created
May 12, 2016 03:06
-
-
Save DiegoNaterasPonce/9f6ab02221b7f5a590d2d788ab7b92e3 to your computer and use it in GitHub Desktop.
#Quiz7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include <cmath> | |
#include <limits> | |
using namespace std; | |
int dot_product(int list1[], int list2[], int number) | |
{ | |
int sum=0; | |
for (int i=0; i < number; i++) | |
{sum=sum + (list1[i]*list2[i]);} | |
return sum; | |
} | |
int main () | |
{ | |
int number; | |
cout<<"Give me the size of the list (a number): "; | |
cin>>number; | |
int sum, list1[number], list2[number]; | |
for (int i=0; i < number; i++) | |
{ | |
cout<<"Tell me the "<<i+1<<" number of the first list: "; | |
cin>>list1[i]; | |
} | |
cout<<endl; | |
for (int i=0; i < number; i++) | |
{ | |
cout<<"Tell me the "<<i+1<<" number of the second list: "; | |
cin>>list2[i]; | |
} | |
cout<<endl; | |
sum=dot_product (list1, list2, number); | |
cout<<"The dot product of the vectors is: "<<sum; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment