Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#β€’3w agoβ€’
56 replies
big poo

why does this code not work???

beginner
Im a beginner to c# and started on GML so please putup with me if im slow
using System;
class Forever
{
public static void Main ()
{
int digits, k;
string storage;

System.Console.WriteLine("amount of digits you need to calculate?");
storage = Console.ReadLine();
digits = int.Parse(storage);
System.Console.WriteLine(digits);

double pi;
double[] sums = new double[digits];

do

sums[k] = 4*((Math.Pow(-1, k))/(2 * k + 1));

k = k + 1;

while(k<digits);

pi = sums.Sum();
}
}
I dont understand why this code doesnt work? For some reason its having a problem with the k = k+1 operation but i defined k outside of the loop.
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

why does this Not work?
C#CC# / help
3y ago
❔ Why does this not work?
C#CC# / help
3y ago
❔ βœ… Why does this not work???
C#CC# / help
3y ago