Computer Science, asked by hhhhyyrfft, 11 months ago

Write a program to find the sum of the series:
s=1-a+a^2-a^3+a^4-a^5......................+a^10

Answers

Answered by Anonymous
8

import java.util.*;

public class Series

{

public static void main(String args[])

{

Scanner in= new Scanner(System.in);

double i,a,s=0;

System.out.println("Enter the value of a");

a= in.nextDouble();

for(i=0;i<=10;i++)

{

if(i%2==0)

s=s+ Math.pow(a,i);

else

s= s-Math.pow(a,i);

}

System.out.println("The sum of the series =" +s);

}

}

Answered by Anonymous
17

&lt;b&gt;&lt;marquee behaviour="alternate"&gt;Hola Mate✌&lt;/marquee&gt;

\boxed{Here\:Is\:Your\:Answer}

#include<stdio.h>

int main() {

int n,i;

int sum=0;

printf("Enter the n i.e. max values of series: ");

scanf("%d",&n);

sum = (n * (n + 1)) / 2;

printf("Sum of the series: ");

#Lipstick Remover ( ˘ ³˘)♥

Similar questions