© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
7 replies
peyzar2᲼᲼

❔ Using WHILE to sum numbers from 10 until sum == 1000

Hello, how to make using function while () {} to make numbers from 10 to be sum until result is 1000 for example:
10 + 10 (first time)
20 + 11 (2th time)
31 + 12 (3rd time)
43 + 13 (4th time) and etc until result is 1000 also to print the last number after +

my broken code:
            int i = 10;
            int a = 0;

            while (i <= 1000)
            {
                a = a + i;
            }

            Console.WriteLine(a);
            int i = 10;
            int a = 0;

            while (i <= 1000)
            {
                a = a + i;
            }

            Console.WriteLine(a);
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

sum of all numbers in between [Answered]
C#CC# / help
4y ago
sum of the even numbers in the fibonacci sequence
C#CC# / help
12mo ago
sum of all numbers divisible by 3 in a string
C#CC# / help
4y ago
❔ How do I restrict user from using numbers in Name
C#CC# / help
4y ago