Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1.  
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. double t,l1,l2,sum=0,arx[100],ary[100],x;
  8.  
  9. cout<<"Enter the number of iteration = ";
  10. cin>>t;
  11. cout<<"Enter upper limit = ";
  12. cin>>l2;
  13. cout<<"Enter lower limit = ";
  14. cin>>l1;
  15. x=(l2-l1)/t;
  16. arx[0]=l1;
  17.  
  18. for(int i=1; i<=t; i++)
  19. {
  20. arx[i] = arx[i-1]+x;
  21. }
  22.  
  23. for(int i=0; i<=t; i++)
  24. {
  25. ary[i] = sqrt((1-pow(arx[i],2)));
  26. }
  27.  
  28. for(int i=1; i<t; i++)
  29. {
  30. sum = sum+2*ary[i];
  31. }
  32. sum = (sum+ary[0]+ary[5])*.5*x;
  33.  
  34.  
  35. cout<<"The summation is = "<<sum;
  36.  
  37.  
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement