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 6751667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:57:15+00:00 2026-05-26T12:57:15+00:00

I’ve written a small program but the answer it gives is always wrong, here

  • 0

I’ve written a small program but the answer it gives is always wrong, here is the code

double radiusc;
double xcenter;
double ycenter;

bool onthecircle(int x,int y);


int main(void)
{
    int inputwait;

    printf("Please enter x coordinate of your center point: ");
    scanf("%d",&xcenter);

    printf("Please enter y coordinate of your center point: ");
    scanf("%d",&ycenter);

    printf("Please enter the radius of the circle: ");
    scanf("%d",&radiusc);

    double left_x = xcenter - radiusc;
    double left_y = ycenter;

    double down_x = xcenter;
    double down_y = ycenter - radiusc;

    if(left_x >= floor(left_x))
    {
        left_x = floor(left_x);
        int (left_x);
    }
    else
    {
        left_x = floor(left_x) + 1;
        int (left_x);
    }

    for(left_x; left_x<=xcenter; left_x++)
    {
        for(left_y;left_y>ycenter-radiusc;left_y--)
        {
            if(onthecircle(left_x,left_y))
                printf("Jest na kole: %d , %d \n", left_x,left_y);
        }
    }

    scanf("%i",&inputwait);

    return 0;
}

bool onthecircle(int x,int y)
{
    double t1= x - xcenter;
    double t2 = x - ycenter;

    if ((t1*t1 + t2*t2) > (0,9 *radiusc*radiusc) &&
        (t1*t1 + t2*t2) < (1,1 *radiusc*radiusc))
        return 1;
    else
        return 0;

}

When I debug, typing 0,0 as my center and r = 1, it gives me the point 0, and some big number, instead of saving 1 as the value for r, it gets a random huge number, and I have no idea why. Any ideas?

  • 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-26T12:57:15+00:00Added an answer on May 26, 2026 at 12:57 pm

    In addition to the problem Ed found, 0,9 is not a valid floating-point constant; you want 0.9. (Locale settings can affect input and output representations; they don’t affect language syntax.)

    The comma in (0,9 *radiusc*radiusc) is a comma operator, not a decimal point; you’re multiplying the square of the radius by 9.

    And you’re missing the #include <stdio.h> and #include <math.h> (for floor() at the top of your program (your compiler might let you get away with that, but it’s not optional).

    And the format in your printf calls is incorrect; you need "%f" or "%g" for `double’.

    More:

    Your use of a double as a loop control variable is questionable. The call scanf("%i",&inputwait); to wait for input before terminating the program without a prompt is user-hostile. There is no need to use global variables. I don’t know what int (left_x); is supposed to do; I think it’s parsed as a declaration (of a variable that you never use), and the parentheses are superfluous. Your use of the type name bool means either that you’re compiling your code as C++, or that you have either a #include <stdbool.h> or a definition of bool that you haven’t bothered to show us.

    That’s about as much debugging as I’m willing to do for now. Fix these errors and try again.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.