Skip to content

Instantly share code, notes, and snippets.

@alonzoibarra97
Created May 3, 2016 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alonzoibarra97/bca025c0d6f71b997c0a7761e2ffcc4d to your computer and use it in GitHub Desktop.
Save alonzoibarra97/bca025c0d6f71b997c0a7761e2ffcc4d to your computer and use it in GitHub Desktop.
#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