Write a program in java to print the sum of following series:
s= 9,99,8,89,7,79,........................1,19
Answers
Answered by
0
⭐hey there!!
import java.util.*;
class sum_series
{
public static void main(String args[])
{
int a=9,b=99,s=0,n,c;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value of n");
n=sc.nextInt();
for(int i=1;i<n;i++)
{
c=a+b;
s=s+c;
a=a-1;
b=b-10;
}
System.out.println("SUM="+s);
}
}
Similar questions