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
1
- Answer: See here!
- Explanation: public class s
- {
- public static void main(int n)
- {
- double x; double sum=0;int p=1;
- for(int i=0;i<n;i++)
- {
- x=Math.sqrt(n);
- if(i%2==0)
- {
- sum=sum+x;
- }
- else if(i%2!=0)
- {
- sum=sum-x;
- }
- p=p+2;
- }
- System.out.print(sun);
- }
- }
Similar questions