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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:00:10+00:00 2026-06-09T05:00:10+00:00

I have to write a program that finds square root of an integer that

  • 0

I have to write a program that finds square root of an integer that is input by a user. But I met a problem – program does not calculate the sqrt. I searched for the problem on the Internet, read all solutions, but they did not help me. On this forum there are many questions on this topic, but solutions described there are not working for me.

Actually, sqrt function does not work when an integer is input by a user. When I set a value it works perfectly. In other words, it finds a sqrt of constant, but not of variable.

I compile it with this code(as everywhere is written) gcc -o sqrt -lm sqrt.c

I am working on Ubuntu.

This is the code:

#include<stdio.h>
#include<math.h>
main()
{
int a;
double b=sqrt(a);
scanf("%i", &a);
printf("sqrt of integer is %lf", b);
getchar();
getchar();
return 0;
}
  • 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-09T05:00:12+00:00Added an answer on June 9, 2026 at 5:00 am
    int a;
    double b=sqrt(a);
    scanf("%i", &a);
    

    You’re using the variable (a) before initializing it. The scanf should go before the sqrt.

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

Sidebar

Related Questions

I have to write a program that sniffs network packets (part1-the simple part). And
I have to write a Java program that tells what coins to give out
I have to write a daemon program that constantly runs in the background and
I wanted to write a program that test if two files are duplicates (have
I have been assigned wit the task to write a program that takes a
I have a program that looks like this. I need to consistently write something
I have a robot that I need to write an autonomous program for. The
I am trying to write a program that takes an input of of n
I have to write an assembly program that will find the minimum of array
I'm trying to write a program that finds strings in a character array and

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.