-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice.cpp
More file actions
49 lines (48 loc) · 752 Bytes
/
Copy pathpractice.cpp
File metadata and controls
49 lines (48 loc) · 752 Bytes
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
#include <iostream>
using namespace std;
void fact(int& num)
{
int count=1;
for (int i=1;i<=num; i++)
{
count*=i;
}
cout<<count<<endl;
}
void power(int& num, int pow=2)
{
int count=1;
for (int i=1;i<=pow;i++)
{
count*=num;
}
cout<<count<<endl;
}
int main ()
{
int num=0,count=1,desecion;
cout<<"What you want to calculate \n enter 1 for Power \t 2 for factorial: ";
cin>>desecion;
if (desecion==2)
{
cout<<"Enter Number: ";
cin>>num;
for (int i=1; i<=num; i++)
{
count*=i;
}
cout<<count<<endl;
//fact ();
}
else
if (desecion==1)
{
int p=0;
cout<<"Enter Number: ";
cin>>num;
cout<<"Enter Power: ";
cin>>p;
power(num,p);
}
return 0;
}