Advertisement
cd62131

Inner Product

Jan 17th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void) {
  4.   int x[] = { 1, 2, 3, 4 };
  5.   int y[] = { 4, 3, 2, 1 };
  6.   int e = sizeof(x) / sizeof(int);
  7.   int z[e];
  8.   int i;
  9.   for (i = 0; i < e; i++) {
  10.     z[i] = x[i] * y[i];
  11.   }
  12.   printf("[");
  13.   for (i = 0; i < e; i++) {
  14.     printf("%d", z[i]);
  15.     if (i < e - 1) printf(", ");
  16.   }
  17.   printf("]\n");
  18.   return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement