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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:18:41+00:00 2026-05-27T00:18:41+00:00

I’m trying to figure out a program in c to calculate the x,y coordinates

  • 0

I’m trying to figure out a program in c to calculate the x,y coordinates in a bolt circle pattern. I’ve got the math part right but can’t figure out how to get it to list the starting angle and coordinates first instead of last and the degrees not to go past 360. Here is the code:

#include <stdio.h>
#include <math.h>

int main()
{
    float x;        //x location
    float y;        //y location
    float h;        //# of holes
    float d;        //diameter of bc
    float a;        //starting angle
    int n;          //hole count

    printf("enter dia of circle\n");
    scanf("%f", &d);
    printf("enter number of holes\n");
    scanf("%f", &h);
    printf("enter starting angle, counter clockwise from 3:00\n");
    scanf("%f", &a);

    float r = d / 2;    //radius
    float k = 360 / h;  //degrees between holes 

    for (n = 0; n < h; n++) {
        a = a + k;

        x = r * (cos(a * M_PI / 180));
        y = r * (sin(a * M_PI / 180));

        printf("%.3f, %.3f, %.2f\n", x, y, a);
    }

    return 0;
}

I’m doing this in c to get the code right then I’ll put it in objective c for the iPhone, what would be the best way to list the output for each x & y coordinate and the angle? For example would I use a table view? Thanks for any advice.

  • 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-27T00:18:42+00:00Added an answer on May 27, 2026 at 12:18 am

    I’d suggest replacing a = a + k with something more like this:

    float base_a;
    printf("enter starting angle, counter clockwise from 3:00\n");
    scanf("%f", &base_a);
    
    for (n = 0; n < h; n++) {
        a = base_a + n*k;
    

    Repeated addition of floating point numbers leads to increased errors. Maybe it won’t matter for this (after all, you’re only using floats rather than doubles — but errors accumulate “faster” with floats than doubles, so it is a more pressing problem) but the fix is easy enough: multiply the difference with the count and add that to a constant base.

    I’m also a little worried about the comparison n < h — n is an int while h is a float. While I’m normally worried about floating-point loop variables, I’m more worried about a float being used for the number of holes. Is that what the problem specifies?

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
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 have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

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.