Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6918785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:54:13+00:00 2026-05-27T09:54:13+00:00

At runtime the program says an index is out of range, but I don’t

  • 0

At runtime the program says an index is out of range, but I don’t know why.

The line that the error messager points out is

Points[counter + ((int)(radius * 100))].X = i;

If that one has an error, the next one (with the same index) must also have an error.

Points[counter + ((int)(radius * 100))].Y = (Points[counter].Y * -1);

Here is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            Circle circle = new Circle(new Point2D(30F, 30F), 10F);
            foreach (Point2D point in circle.Points)
            {
                Console.Write(point.X + " = X\n" + point.Y + " = Y");
                Console.ReadKey();
            }
        }
    }

    public struct Point2D
    {
        public float X;
        public float Y;

        public Point2D(float x, float y)
        {
            this.X = x;
            this.Y = y;
        }
    }

    class Circle
    {
        public Point2D[] Points;
        float h, k;
        float radiusStart, radiusEnd;
        int counter;

        public Circle(Point2D location, float radius)
        {
            Points = new Point2D[(int)(radius * 201)];
            h = location.X;
            k = location.Y;
            radiusStart = h - radius;
            radiusEnd = h + radius;

            for (float i = radiusStart; i <= radiusEnd; i++)
            {
                Points[counter].X = i;
                Points[counter].Y = (float)(Math.Sqrt((radius * radius) - ((i - h) * (i - h))) + k);
                Points[counter + ((int)(radius * 100))].X = i;
                Points[counter + ((int)(radius * 100))].Y = (Points[counter].Y * -1);
                counter++;
            }

            counter = 0;
        }
    }
}

Thank you in advance

Adrian Collado

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:54:14+00:00Added an answer on May 27, 2026 at 9:54 am

    I’ve seen bizarre behavior with: i = i++

    Try changing for (float i = radiusStart; i <= radiusEnd; i = i++) to just use i++ instead of i = i++.

    Even if it doesn’t fix your issue, it’s much better form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some overflow runtime error happens when my C++ program is trying to write some
Let's say I wrote a program containing an algorithm that had an exponential runtime
I wrote a Java program that can execute another Java program during runtime. The
I am receiving an error that says The application was unable to start correctly
I'm writing a report and presentation for my college titled Protection runtime program in
We host the .NET runtime as part of a Win32 program, and lately it
Does Visual C++ runtime imply Windows platform? I mean if I write a program
I have the next code: Process p = Runtime.getRuntime().exec(args); and I want my program
My runtime environment is still on JDK1.4 but I like the Solr features related
can anyone tell me whats wrong in the following program that accepts 1 or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.