-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector.cpp
More file actions
60 lines (60 loc) · 1.09 KB
/
Vector.cpp
File metadata and controls
60 lines (60 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<iostream>
using namespace std;
class vec
{
int a,b,c;
public:
void create()
{
cout<<"Enter a,b,c in ai+bj+ck"<<endl;
cin>>a>>b>>c;
}
void display()
{
cout<<"The vector is: "<<a<<"i + "<<b<<"j + "<<c<<"k "<<endl;
}
void modify()
{
char x;
cout<<"Enter the element you want to modify: \n a, b or c? "<<endl;
cin>>x;
if(x=='a')
{
cout<<"Enter modified a: "<<endl;
cin>>a;
}
else if(x=='b')
{
cout<<"Enter modified a: "<<endl;
cin>>b;
}
else if(x=='c')
{
cout<<"Enter modified a: "<<endl;
cin>>c;
}
else
{
cout<<"Wrong entry"<<endl;
}
}
void scalar()
{
int k;
cout<<"Enter the scalar multiplication factor: "<<endl;
cin>>k;
a=k*a;
b=b*k;
c=c*k;
}
};
int main()
{
vec v1;
v1.create();
v1.display();
v1.modify();
v1.display();
v1.scalar();
v1.display();
}