Computer Science, asked by anindyaadhikari13, 5 months ago

Java program to find sum of 100 positive integers using 1 variable. ​

Answers

Answered by harshika7257
0

Answer:

Using Java while Loop

public class SumOfNaturalNumber2.

{

public static void main(String[] args)

{

int num = 100, i = 1, sum = 0;

//executes until the condition returns true.

while(i <= num)

{

Answered by MalayaDhal
0

Explanation:

import java.util.*

class p1

{

void read()

{

....

....

for(int a=1;a<=100;a++)

int s=s+a;

System.out.println (s);

}

}

Similar questions