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;
Select
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.
Deloitte Automation Test Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits