Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************************************/
- /* CS133uF16 Pro. 7 - Due 11/06/2016 */
- /* Track 1 -- Erin Lewin */
- /*********************************************/
- #include <stdio.h>
- int main(void)
- {
- int i, temp, mult = 0, total, limit;
- char reply = 'y';
- while (reply == 'y')
- {
- printf("Enter number of terms (up to 15): ");
- scanf(" %d", &limit);
- int vector1[ limit ];
- int vector2[ limit ];
- printf("Enter first vector (e.g. 4 3 7): ");
- for (i = 0; i < limit; i = i + 1)
- {
- scanf(" %d", &temp);
- vector1[i] = temp;
- }
- printf("Enter second vector (e.g. 5 4 8): ");
- for (i = 0; i < limit; i = i + 1)
- {
- scanf(" %d", &temp);
- vector2[i] = temp;
- }
- i = 0;
- for (i = 0; i < limit; i = i + 1)
- {
- mult = vector1[i] * vector2[i];
- total = total + mult;
- }
- printf("The 'dot product' is %d\n", total);
- printf("Compute another dot product? (y/n) ");
- scanf(" %c", reply);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement