/* To determine dot product, cross product and resultant of two vectors */
#include<stdio.h>
#include<math.h>
int main()
{
float a1, a2, a3, b1, b2, b3, AdotB, AXBx, AXBy, AXBz, AplusBx, AplusBy, AplusBz;
printf("Enter the 1st vector components:\n");
scanf("%f%f%f", &a1, &a2, &a3);
printf("Enter the 2nd vector components:\n");
scanf("%f%f%f", &b1, &b2, &b3);
AdotB=a1*b1+a2*b2+a3*b3;
AXBx=(a2*b3-a3*b2);
AXBy=(a3*b1-a1*b3);
AXBz=(a1*b2-a2*b1);
AplusBx=(a1+b1);
AplusBy=(a2+b2);
AplusBz=(a3+b3);
printf("The dot product of the vectors is: A.B=%f", AdotB);
printf("\nThe cross product of the vectors is: AXB=%fi+%fj+%fk", AXBx, AXBy, AXBz);
printf("\nThe resultant of the vectors is: A+B=%fi+%fj+%fk\n", AplusBx, AplusBy, AplusBz);
return(0);
}
#include<stdio.h>
#include<math.h>
int main()
{
float a1, a2, a3, b1, b2, b3, AdotB, AXBx, AXBy, AXBz, AplusBx, AplusBy, AplusBz;
printf("Enter the 1st vector components:\n");
scanf("%f%f%f", &a1, &a2, &a3);
printf("Enter the 2nd vector components:\n");
scanf("%f%f%f", &b1, &b2, &b3);
AdotB=a1*b1+a2*b2+a3*b3;
AXBx=(a2*b3-a3*b2);
AXBy=(a3*b1-a1*b3);
AXBz=(a1*b2-a2*b1);
AplusBx=(a1+b1);
AplusBy=(a2+b2);
AplusBz=(a3+b3);
printf("The dot product of the vectors is: A.B=%f", AdotB);
printf("\nThe cross product of the vectors is: AXB=%fi+%fj+%fk", AXBx, AXBy, AXBz);
printf("\nThe resultant of the vectors is: A+B=%fi+%fj+%fk\n", AplusBx, AplusBy, AplusBz);
return(0);
}
Comments
Post a Comment