===========================================================================
CODING
#include<all.h>
void main()
{
label:
clrscr();
float n=0,angle=0,a=0,b=0,c=0,d=0,p=0,q=0,r=0,R=0,Ra=0,Rb=0,Rc=0,m=0,m1=0,m2=0,B=0;
char ch;
cout<<"\nVector Calculator Fuctions:-";
cout<<"\n Triangle(or //gm) law of Vector Add.: 1";
cout<<"\n Magnitude: 2";
cout<<"\n Dot product: 3";
cout<<"\n Cross product: 4";
cout<<"\n Unit Vector: 5";
cout<<"\n Polygon law of Vector Add.: 6";
cout<<"\n\n ¯Enter number of Function: ";
cin>>n;
if(n<=6);
else
{
cout<<"\nWrong Input!\n Try Again?(y/n): ";
cin>>ch;
if(ch=='y' || ch=='Y')
goto label;
else
exit(0);
}
clrscr();
if(n==1)
{
cout<<"\nEnter Magnitude of 1st Vector: ";
cin>>m1;
cout<<"\nEnter Magnitude of 2nd Vector: ";
cin>>m2;
cout<<"\nEnter the Angle b/w the Vectors: ";
cin>>angle;
angle=angle*M_PI/180;
R=sqrt(m1*m1+m2*m2+2*m1*m2*cos(angle));
B=atan(m2*sin(angle)/(m1+m2*cos(angle)));
cout<<"\n\n\n\t\tResultant="<<R<<"\t\tá="<<B<<"rad or á="<<B*180/M_PI<<"ø";
}
else if(n==2)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
m=sqrt((a*a+b*b+c*c));
gotoxy(3,5);
cout<<"Magnitude="<<m;
}
else if(n==3)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(30,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
gotoxy(30,3);
cin>>p;
gotoxy(34,3);
cin>>q;
gotoxy(38,3);
cin>>r;
gotoxy(15,5);
R=a*p+b*q+c*r;
angle=acos(R/(sqrt(a*a+b*b+c*c)*sqrt(p*p+q*q+r*r)));
gotoxy(20,7);
cout<<"DOT product="<<R;
gotoxy(20,8);
cout<<"Angle b/w them: "<<angle<<"rad or :"<<angle*180/M_PI<<"ø";
}
else if(n==4)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(30,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
gotoxy(30,3);
cin>>p;
gotoxy(34,3);
cin>>q;
gotoxy(38,3);
cin>>r;
gotoxy(15,5);
Ra=b*r-q*c;
Rb=c*p-r*a;
Rc=a*q-p*b;
R=sqrt(Ra*Ra+Rb*Rb+Rc*Rc);
angle=acos(R/(sqrt(a*a+b*b+c*c)*sqrt(p*p+q*q+r*r)));
gotoxy(20,7);
cout<<"CROSS product= i("<<Ra<<")+j("<<Rb<<")+k("<<Rc<<")";
gotoxy(20,8);
cout<<"Angle b/w them: "<<angle<<"rad or :"<<angle*180/M_PI<<"ø"<<"\tMagnitude="<<R;
}
else if(n==5)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
m=sqrt(a*a+b*b+c*c);
gotoxy(3,5);
cout<<"Unit Vector= [i("<<a<<")+j("<<b<<")+k("<<c<<")]/"<<m;
}
else if(n==6)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(30,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
gotoxy(30,3);
cin>>p;
gotoxy(34,3);
cin>>q;
gotoxy(38,3);
cin>>r;
gotoxy(15,5);
Ra=a+p;
Rb=b+q;
Rc=c+r;
R=sqrt(Ra*Ra+Rb*Rb+Rc*Rc);
gotoxy(20,7);
cout<<"Resultant= i("<<Ra<<")+j("<<Rb<<")+k("<<Rc<<")";
gotoxy(20,8);
cout<<"Magnitude="<<R;
}
getch();
}
CODING
#include<all.h>
void main()
{
label:
clrscr();
float n=0,angle=0,a=0,b=0,c=0,d=0,p=0,q=0,r=0,R=0,Ra=0,Rb=0,Rc=0,m=0,m1=0,m2=0,B=0;
char ch;
cout<<"\nVector Calculator Fuctions:-";
cout<<"\n Triangle(or //gm) law of Vector Add.: 1";
cout<<"\n Magnitude: 2";
cout<<"\n Dot product: 3";
cout<<"\n Cross product: 4";
cout<<"\n Unit Vector: 5";
cout<<"\n Polygon law of Vector Add.: 6";
cout<<"\n\n ¯Enter number of Function: ";
cin>>n;
if(n<=6);
else
{
cout<<"\nWrong Input!\n Try Again?(y/n): ";
cin>>ch;
if(ch=='y' || ch=='Y')
goto label;
else
exit(0);
}
clrscr();
if(n==1)
{
cout<<"\nEnter Magnitude of 1st Vector: ";
cin>>m1;
cout<<"\nEnter Magnitude of 2nd Vector: ";
cin>>m2;
cout<<"\nEnter the Angle b/w the Vectors: ";
cin>>angle;
angle=angle*M_PI/180;
R=sqrt(m1*m1+m2*m2+2*m1*m2*cos(angle));
B=atan(m2*sin(angle)/(m1+m2*cos(angle)));
cout<<"\n\n\n\t\tResultant="<<R<<"\t\tá="<<B<<"rad or á="<<B*180/M_PI<<"ø";
}
else if(n==2)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
m=sqrt((a*a+b*b+c*c));
gotoxy(3,5);
cout<<"Magnitude="<<m;
}
else if(n==3)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(30,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
gotoxy(30,3);
cin>>p;
gotoxy(34,3);
cin>>q;
gotoxy(38,3);
cin>>r;
gotoxy(15,5);
R=a*p+b*q+c*r;
angle=acos(R/(sqrt(a*a+b*b+c*c)*sqrt(p*p+q*q+r*r)));
gotoxy(20,7);
cout<<"DOT product="<<R;
gotoxy(20,8);
cout<<"Angle b/w them: "<<angle<<"rad or :"<<angle*180/M_PI<<"ø";
}
else if(n==4)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(30,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
gotoxy(30,3);
cin>>p;
gotoxy(34,3);
cin>>q;
gotoxy(38,3);
cin>>r;
gotoxy(15,5);
Ra=b*r-q*c;
Rb=c*p-r*a;
Rc=a*q-p*b;
R=sqrt(Ra*Ra+Rb*Rb+Rc*Rc);
angle=acos(R/(sqrt(a*a+b*b+c*c)*sqrt(p*p+q*q+r*r)));
gotoxy(20,7);
cout<<"CROSS product= i("<<Ra<<")+j("<<Rb<<")+k("<<Rc<<")";
gotoxy(20,8);
cout<<"Angle b/w them: "<<angle<<"rad or :"<<angle*180/M_PI<<"ø"<<"\tMagnitude="<<R;
}
else if(n==5)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
m=sqrt(a*a+b*b+c*c);
gotoxy(3,5);
cout<<"Unit Vector= [i("<<a<<")+j("<<b<<")+k("<<c<<")]/"<<m;
}
else if(n==6)
{
gotoxy(10,3);
cout<<"__i+__j+__k";
gotoxy(30,3);
cout<<"__i+__j+__k";
gotoxy(10,3);
cin>>a;
gotoxy(14,3);
cin>>b;
gotoxy(18,3);
cin>>c;
gotoxy(30,3);
cin>>p;
gotoxy(34,3);
cin>>q;
gotoxy(38,3);
cin>>r;
gotoxy(15,5);
Ra=a+p;
Rb=b+q;
Rc=c+r;
R=sqrt(Ra*Ra+Rb*Rb+Rc*Rc);
gotoxy(20,7);
cout<<"Resultant= i("<<Ra<<")+j("<<Rb<<")+k("<<Rc<<")";
gotoxy(20,8);
cout<<"Magnitude="<<R;
}
getch();
}
===========================================================================
No comments:
Post a Comment