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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:17:05+00:00 2026-06-13T18:17:05+00:00

here is my snippet of code: float square_root(x) float x; { ……. } int

  • 0

here is my snippet of code:

float square_root(x)
float x;
{
 .......
}

int main(){
    printf("Square_root 2 = %f\n", square_root(4));
}

When I pass number 4.0 to the square_root() function, x parameter inside the function is 4.0000000 so its ok.
But when I pass just 4 (like in example), x variable inside the function becomes 1.976262583365e-323#DEN

Why does that happen?

  • 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-06-13T18:17:07+00:00Added an answer on June 13, 2026 at 6:17 pm

    You’re using the old style of function declaration, where the argument types are listed separately. See C function syntax, parameter types declared after parameter list

    As you are passing an int, it’s not being converted to float by default. Your function, though, is interpreting the argument as a float, which gives undesirable results.

    The modern approach is to include the argument type in the function declaration, which will allow your int argument to be automatically converted to a float.

    float square_root(float x)
    {
         .......
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
Here is the following code-snippet I'm using in my Google Spreadsheet onEdit() function: else
here is the relevent code snippet: public static Rand searchCount (int[] x) { int
Here is a code snippet which I have written: let Foo (a : (int
Here is my code snippet: float ab(float); and later if(ab(temp)<ab(a[r][c])) { do something; }
Here's the code snippet: float pNum = 9.2; char* l_tmpCh = new char[255]; sprintf_s(l_tmpCh,
Here's a snippet of code I saw on the web and I'm wondering if
Here is my code snippet where I'am taking confidence with initialization blocks class Father{
Here's the relevant code snippet. public static Territory[] assignTerri (Territory[] board, String[] colors) {
Here is a snippet of my code $fp = fsockopen($s['url'], 80, $errno, $errstr, 5);

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.