My program basically asks the users for a value (s) then calculates and displays the First, Middle, Last, and Final. The users have a choice to enter the value either in integer, real or character. If the user enters it in real or character, it will be converted into integer value before the required value is computed. I have written the power , factorial and the sigma functions which I will use in calculating the first, middle and the last. Can somebody assist in checking my codes to see if its correct and show how I will those functions to calculate the first and the last which a bit more complicated?

First = X^1/1! - X^3/3! + X^5/5! - X^7/7! + X^9/9! - ....X^n/n!

Middle = n sigma i = 1 sqrt(i/x)

last = 1- X^2/2! + X^4/4! - X^6/6! + X^8/8! - ....X^n/n!

Final = first/last + middle

```
#include<iostream>
#include<cmath>
using namespace std;
int powerfunc (int x, int n)
{
int x, n;
int p, i;
while (i <=n)
{
p = p * x;
i = i + 1;
return p;
}
}
int factorial (int n)
{
int i, n;
int f = 1;
for (i = 1; i <= f; i++)
{
f *= i;
return f;
}
}
int sigma(int x, int n)
{
int i = 1, sum = 0;
int x, n;
while (i <= n)
{
sum += i * i;
i++;
sum = sqrt(sum/x)
return sum;
}
}
int main()
{
int x, n;
int first, middle, last, final;
cout << “Please enter the value for x” << endl;
cin >> x;
cout << “Please enter the value for n” << endl;
cin >>n;
middle = sigma(x, n)
final = fist/(last + middle);
cout << “The value for first is << first << endl;
cout << “The value for middle is << middle << endl;
cout << “The value for last is << last << endl;
cout << “The value for final is << final << endl;
return 0;
}
```