write a program of each of the following1+2+3+ – +n
Answers
Answered by
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
Science,
3 months ago
History,
3 months ago
English,
8 months ago
Social Sciences,
8 months ago
Math,
1 year ago