Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Factorial.cpp : 1)Factorial N! = N * (N-1)!
- // 2)Pow Operation
- //
- #include <iostream>
- #include <math.h>
- using namespace std;
- int Fact(int *ptra)
- {
- if (*ptra == 0)
- {
- return 0;
- }
- if (*ptra == 1)
- {
- return 1;
- }
- int x = *ptra - 1;
- return *ptra * Fact(&x);
- }
- double powOperation(double *ptrb, double c)
- {
- *ptrb = pow(*ptrb, c);
- return *ptrb;
- }
- int main()
- {
- //Factorial operation
- int a = 5;
- cout << Fact(&a) << endl;
- //powOperation
- double b = 3;
- powOperation(&b,5);
- cout << b;
- }
Add Comment
Please, Sign In to add comment