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

  • Home
  • SEARCH
  • 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 6753539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:10:24+00:00 2026-05-26T13:10:24+00:00

In my homework for my C class, we have to write a program that

  • 0

In my homework for my C class, we have to write a program that checks if an integer is prime. I am getting an error at the sqrt() function. My professor told me that num must be an integer and we must use the sqrt() function. I thought the problem was that the sqrt() function can’t be used on an integer but my professor told me that it can, and that I was getting an error from something else. Do you guys see the problem?

int primality(int num)
{

int isprime;

    /*check if num is prime*/
    for (int i = 2; i <= sqrt(num); i++)
    {
        if (num % i == 0)
            isprime = 0; /*is not prime*/
        else 
            isprime = 1; /*is prime*/
    }

    if (isprime == 0)
        return 0;
    elseif (isprime == 1)
        return 1;
}

EDIT:
Yes I am using math.h and compiling as C code.

The error msg is “Error: More than one instance of overloaded function “sqrt” matches the argument list.

  • 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-26T13:10:25+00:00Added an answer on May 26, 2026 at 1:10 pm

    The C language does not have “overloads”. My bet is that you are compiling your code as C++, not C. If you’re using GCC, compile with gcc, not g++. If you are using Visual Studio, there is an option in the properties of the project:

    1. right click on your project
    2. click properties
    3. click on C/C++
    4. click on advanced
    5. set the property “compile as” to C Code (/TC)

    In either case, name your file with a .c extension (lowercase ‘c’).

    Indeed, in C there is only one sqrt, defined as

    double sqrt(double);
    

    and integers convert to double.

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

Sidebar

Related Questions

Here is my homework question: Write a program that asks for a film name
I have been trying to write a recursive function that searches a stack, but
In my homework, I have to design a class Message; among other attributes, it
For a homework assignment I was given a Card class that has enumerated types
I have one class that declares an enumeration type as: public enum HOME_LOAN_TERMS {FIFTEEN_YEAR,
I have this homework. And I am beginner C# program, and now learn the
I have done a homework assignment, here is the problem statement: Your program should
I'm working on some homework for my compiler class and I have the following
I know that I am missing something simple here. I have got this homework
I have to store scheduled events, (like say class times, for example) that can

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.