Write a Java program to calculate the sum of the first 100 natural numbers.

AnswerBot
1y
Java code to print sum of 100 numbers
Create an array of 100 numbers
Use a loop to iterate through the array and calculate the sum
Print the sum at the end
Yatam Pakkira Reddy
26d
Main()
{
int sum=0;
for(int i=1;i<=100;i++)
{
Sum=sum+i;
}
Println(sum);
}

comfortablebluefish
6mo
works at
Use int sum= (N*(N+1))/2;
Add answer anonymously...
Deloitte Automation Test Engineer interview questions & answers
An Automation Test Engineer was asked 11mo agoQ. How would you automate a test case for the MakeMyTrip website?
An Automation Test Engineer was asked 12mo agoQ. How do you switch to another tab using Selenium?
An Automation Test Engineer was asked 12mo agoQ. Write a Java program to calculate the sum of the first 100 natural numbers.
Popular interview questions of Automation Test Engineer
An Automation Test Engineer was asked 11mo agoQ1. How would you automate a test case for the MakeMyTrip website?
An Automation Test Engineer was asked 12mo agoQ2. How do you switch to another tab using Selenium?
An Automation Test Engineer was asked 12mo agoQ3. Write a Java program to calculate the sum of the first 100 natural numbers.
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

