Page MenuHomec4science

exercise01-3.cpp
No OneTemporary

File Metadata

Created
Sun, Jul 6, 19:10

exercise01-3.cpp

/*
* exercise-template.cpp <--- The name of the source file goes here
*
* <--- Description of the program goes here.
*
* Created on: September 02, 2015 <--- Fill in the date here
* Author: Davide Forti <davide.forti@epfl.ch> <--- Fill in your name (and e-mail) here
*/
/*
* Any headers you need to include should be specified on the next lines
*/
#include <iostream>
#include <cmath>
int main(int argc, char* argv[])
{
double array1[3] = {5.0, 1.0, 2.0};
double array2[3] = {2.0, 8.0, 4.0};
double dotProduct;
for (int i=0; i<4; i++)
{
dotProduct += array1[i] * array2[i];
}
std::cout << "Scalar product result :" << dotProduct;
std::cout << " \n";
return 0;
}

Event Timeline