Computer Science, asked by pramodtamang171, 8 months ago

write a program of each of the following1+2+3+ – +n​

Answers

Answered by InfiniteSoul
2

import java.io.*;

class abc

{

public static void main(String args[])throws IOException

{

int a , b , c = 0 ;

InputStreamReader read = new InputStreamReader(System.in);

BufferedReader in = new BufferedReader(read);

System.out.println( " Enter the no. of times ");

a = Integer.parseInt( in .readLine ());

{

if (b = 1 ; b< = a ; b++ )

c = c + b ;

}

System.out.println( "Sum of the series = " + c );

}

}

Similar questions