write a program to print first 40natural numbers and their sum in java programming
Answers
Answered by
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
Accountancy,
21 hours ago
History,
21 hours ago
India Languages,
21 hours ago
Computer Science,
1 day ago
Physics,
1 day ago
Hindi,
8 months ago
Computer Science,
8 months ago