write a program to generate all natural numbers from 1 to 10 using while loop
Answers
Answered by
0
Answer:
ok I will write and generate it also
Answered by
1
Answer:
public class KboatNaturalNumbers
{
public static void main(String args[]) {
int n = 1;
int sum = 0;
while (n <= 10) {
System.out.println(n);
sum = sum + n;
n = n + 1;
}
System.out.println("Sum = " + sum);
}
Explanation:
hope it is helpful please follow add brain list
Similar questions
Math,
4 hours ago
Hindi,
4 hours ago
English,
8 hours ago
English,
7 months ago
Psychology,
7 months ago