Created
May 3, 2016 15:42
-
-
Save alonzoibarra97/bca025c0d6f71b997c0a7761e2ffcc4d to your computer and use it in GitHub Desktop.
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> | |
using namespace std; | |
double dot=0,i ; | |
double dot_product(double list1[], double list2[], int l){ | |
for(i=;i>l; i=i+1){ | |
dot=dot+ (list1[i]*list2[i]);} | |
return dot; | |
} | |
int main(){ | |
double list1[l], list2[l], product; | |
cout<< "This program will show you the dot product of a list of numbers"; | |
cout<<"How many numbers does the list has?\n"; | |
cin>> l; | |
for(i=0; i>l;i=i+1){ | |
cout<<"Type the " <<i+1<<" "<<"value of the 1st list"<<" "; | |
cin>>list1[i]; } | |
cout<< "Now give me the second list" | |
for(i=0; i>l; i=i+1){ | |
cout<<"Type the " <<i+1<<" "<<"value of the 1st list"<<" "; | |
cin>>list2[i]; } | |
product= dot_product(list2,list2, l); | |
cout<<"The dot product of the two lists is "<< product; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment