Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int factorial(int num);
- double funcionSeno1(int x, int n);
- void main()
- {
- int x;
- int num = 10;
- int opcion;
- bool salir = false;
- do
- {
- cout << "1 Calculo del seno: "<<endl;
- cout << "2 Digito: "<<endl;
- cout << "3 Digito: "<<endl;
- cin >> opcion;
- switch (opcion)
- {
- case 1:
- cout << "Valor de x: ";
- cin >> x;
- cout << "El seno de x es: " << funcionSeno1(x, num)<<endl;
- break;
- case 2:
- case 3:
- salir = true;
- break;
- }
- }
- while (salir==false);
- system("pause");
- }
- double funcionSeno1(int x, int n)
- {
- double seno=0;
- for (int i = 0; i <=n; i=i+1)
- {
- seno = seno + (double)pow(-1, i)*pow(x, 2 * i + 1) / factorial(2 * i + 1);
- }
- return seno;
- }
- int factorial(int num)
- {
- int fac = 1;
- if (num == 0 || num == 1) fac = 1;
- for (int i = 1; i <=num; i++)
- {
- fac = fac*i;
- }
- return fac;
- }
- int digito(int p, int num)
- {
- int digito;
- int contador=0;
- num = abs(num);
- do {
- digito = num%10;
- num = num / 10;
- contador++;
- if (p+1 == contador)
- break;
- } while (num>0);
- if (p+1>contador) digito = -1;
- return digito;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement