31 lines
661 B
C
31 lines
661 B
C
|
/* 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;
|
|||
|
}
|
|||
|
|
|||
|
|