inrprod1.cpp

inrprod1.cpp

#include ‹stl.h›

#include ‹iostream.h›

#include ‹string.h›

int main() {

 vector‹int› v1(3);

 vector‹int› v2(v1.size());

 for (int i = 0; i ‹ v1.size(); i++) {

  v1[i] = i + 1;

  v2[i] = v1.size() - i;

 }

 ostream_iterator‹int› iter(cout, " ");

 cout ‹‹ "Inner product(sum of products) of: ";

 copy(v1.begin(), v1.end(), iter);

 cout ‹‹ " ";

 copy(v2.begin(), v2.end(), iter);

 int result = inner_product(v1.begin(), v1.end(), v2.begin(), 0);

cout ‹‹ " is: " ‹‹ result ‹‹ endl;

return 0;

}