Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- double integral(int n, double x)
- {
- if (n == 1)
- return -cos(x);
- if (n == 2)
- return (x/2)-((1/4)*sin(2*x));
- if (n > 2)
- return -(pow(sin(x), n-1)*cos(x))/n + ((n-1)/n)*integral(n-2, x);
- }
- int main()
- {
- double x = 0.0; int n = 0;
- printf("%s", "Enter x: \n");
- scanf("%lf", &x);
- printf("%s", "Enter n: \n");
- scanf("%d", &n);
- double result = integral(n, x);
- printf("%s %f","Result: ",result);
- getchar();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement