Computer Science, asked by shirisha1981, 8 months ago

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 AjayKumarr676
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