forked from nirala96/open_source_start
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode1.cpp
More file actions
67 lines (56 loc) · 1.36 KB
/
code1.cpp
File metadata and controls
67 lines (56 loc) · 1.36 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
61
62
63
64
65
66
#include<iostream>
using namespace std;
struct Sample1
{
void getx()
{
cin>>x;
}
int putx()
{
return x;
}
int factorial()
{
int prod=1;
for(int i=1; i<=x; i++)
prod*=i;
return prod;
}
private:
int x;
};
class Sample2
{
int x;
public:
void getx()
{
cin>>x;
}
int putx()
{
return x;
}
int factorial()
{
int prod=1;
for(int i=1; i<=x; i++)
prod*=i;
return prod;
}
};
int main()
{
Sample1 s1;
Sample2 s2;
cout<<"Enter the value of x for s1:";
s1.getx();
cout<<"Enter the value of x for s2:";
s2.getx();
cout<<"\n S1 = "<<s1.putx();
cout<<"\nFactorial ="<<s1.factorial();
cout<<"\n S2 = "<<s2.putx();
cout<<"\nFactorial = "<<s2.factorial();
return 1;
}