C/Adding Vectors.c
2024-05-13 11:09:46 -05:00

30 lines
661 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Adding Vectors
*
* A Program that adds vectors given the components.
*/
#include <stdio.h>
#include <stdlib.h>
int main() {
float u1, u2, v1, v2; /* Components */
/* Prompt user for variables */
printf("Enter the first component of vector 𝐮 (𝑢₁): ");
scanf("%f", &u1);
printf("Enter the second component of vector 𝐮 (𝑢₂): ");
scanf("%f", &u2);
printf("Enter the first component of vector 𝐯 (𝑣₁): ");
scanf("%f", &v1);
printf("Enter the second component of vector 𝐯 (𝑣₂): ");
scanf("%f", &v2);
/* Print the sum of the vectors */
printf("𝐮 + 𝐯 = <%.2f, %.2f>\n", u1 + v1, u2 + v2);
return 0;
}