Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Scalar Product */
- /* Language: C++ */
- #include <iostream.h>
- #include <conio.h>
- template <class type>
- class vector
- {
- type a,b,c;
- public:
- /* vector()
- {
- seconds=minute=hour=0;
- }*/
- vector(type ta,type tb,type tc)
- {
- a = ta;
- b=tb;
- c=tc;
- }
- type scalar_product(vector& vct1)
- {
- type result=(a*vct1.a)+(b*vct1.b)+(c*vct1.c);
- return result;
- }
- };
- int main()
- {
- system("cls");
- /********************************** Int Vectors ****************************************/
- int a,b,c;
- cout<<"\nEnter Vector 1 of Integer Type( (a)i / (b)j / (c)k ) : \n";
- cin>>a>>b>>c;
- cout<<"\nGiven Vector is: "<<a<<"i+"<<b<<"j+"<<c<<"k\n";
- vector <int> vct_int_1 (a,b,c);
- cout<<"\nEnter Vector 2 of Integer Type( (a)i / (b)j / (c)k ) : \n";
- cin>>a>>b>>c;
- cout<<"\nGiven Vector is: "<<a<<"i+"<<b<<"j+"<<c<<"k\n";
- vector <int> vct_int_2 (a,b,c);
- int pdt_int;
- cout<<"\nScalar Product of the Given two Integer Vectors is: "<<vct_int_1.scalar_product(vct_int_2);
- /********************************** Float Vectors ****************************************/
- float d,e,f;
- cout<<"\n\n\nEnter Vector 1 of Integer Type( (a)i / (b)j / (c)k ) : \n";
- cin>>d>>e>>f;
- cout<<"\nGiven Vector is: "<<d<<"i+"<<e<<"j+"<<f<<"k\n";
- vector <float> vct_float_1 (d,e,f);
- cout<<"\nEnter Vector 2 of Integer Type( (a)i / (b)j / (c)k ) : \n";
- cin>>d>>e>>f;
- cout<<"\nGiven Vector is: "<<d<<"i+"<<e<<"j+"<<f<<"k\n";
- vector <float> vct_float_2 (d,e,f);
- float pdt_float;
- cout<<"\nScalar Product of the Given two Float Vectors is: "<<vct_float_1.scalar_product(vct_float_2);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement