Computer Science, asked by tiyastarafdar06, 1 month ago

write a program to find the sum of 1st 10 odd natural numbers in java using while loop. ​

Answers

Answered by salmanhussain008
0

Answer:

The positive integers 1, 2, 3, 4 etc. are known as natural numbers. Here we will see three programs to calculate and display the sum of natural numbers.

First Program calculates the sum using while loop

Second Program calculates the sum using for loop

Third Program takes the value of n(entered by user) and calculates the sum of n natural numbers

To understand these programs you should be familiar with the following concepts of Core Java Tutorial:

Answered by BrainlyProgrammer
8

Answer:

class odd{

public static void main(String ar []){

int I=1;

while (I<=20){

s+=I;

I+=2;

}

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

}

}

Similar questions