Math, asked by dlaharibtech, 2 months ago

write a program for natural numbers in array list​

Answers

Answered by TrexRoar
4

Answer:

This is the Program For finding natural number in Array list

public class SumNatural {

    public static void main(String[] args) {

       int num = 100, sum = 0;

       for(int i = 1; i <= num; ++i)

       {

           // sum = sum + i;

           sum += i;

        }

       System.out.println("Sum = " + sum);

   }

}

The above program loops from 1 to the given num(100) and adds all numbers to the variable

Hope it Help's you

Drop some Thanks &

Mark as Brainliest

Similar questions