Computer Science, asked by idkkk70lolllll, 16 days ago

write a Java program to demonstrate this:
(also pls studiouspal123 don't even help me. I srsly need this ans so plss)

Attachments:

Answers

Answered by desu27072006
1
  1. Answer: See here!
  2. Explanation: public class s
  3. {
  4. public static void main(int n)
  5. {
  6. double x; double sum=0;int p=1;
  7. for(int i=0;i<n;i++)
  8. {
  9. x=Math.sqrt(n);
  10. if(i%2==0)
  11. {
  12. sum=sum+x;
  13. }
  14. else if(i%2!=0)
  15. {
  16. sum=sum-x;
  17. }
  18. p=p+2;
  19. }
  20. System.out.print(sun);
  21. }
  22. }
Similar questions