How to write a C Program to find the The dot product of two vectors in C Programming Language ?
Solution:
/*The Dot Of Two Vectors*/
#include <stdio.h> #include <stdlib.h> void main() { int x, r; int v1[3], v2[3]; v1 = {1, 2, 3}; v2 = {4, 5, 6}; for (x = 0, r = 0; x < 3; x ++) { r += v1[x] * v2[x]; } printf("Produsul scalar este: %d\n", r); }