Computer Science, asked by swarna6520, 1 day ago

write a program to print first 40natural numbers and their sum in java programming​

Answers

Answered by Sanskar260
0

class numbers

{

public static void main(String args [])

{

int sum = 0;

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

{

System.out.println(i);

sum = sum + i;

. }

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

}

}

Similar questions