Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #208 Formula with arrays

Given the arrays a,b,c,d of equal length and the scalar e, calculate a = e*(a+b*c+cos(d)).
Store the results in a.

#include <math.h>
  for (int i=0; i<n; i++)
    a[i] = e*(a[i]+b[i]*c[i]+cos(d[i]));

Assume n is the length.

New implementation...
< >
tkoenig