Write a program to find the sum of all the natural numbers from 1 to 72 using for loop in static initialisation with tracing and variable description table
Answers
Answered by
9
import java.util.*;
public class Scanner
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int a,s=0;
for(a=1;a<=72;a++)
{
s=s+a;
System.out.println("The sum of the numbers is="+s);
}
}
}
Similar questions
Computer Science,
4 months ago
Social Sciences,
4 months ago
Computer Science,
4 months ago
Math,
10 months ago
English,
10 months ago
Math,
1 year ago