An error occurred while calling the sqrt () function in vi.

Source: Internet
Author: User
An error occurred while calling the sqrt () function in vi. -- Linux general technology-Linux programming and kernel information. The following is a detailed description. When calling the sqrt () function in vi and debugging with gcc, the following message is displayed: undefined reference to 'sqrt ', collect2: id returned 1 exit status. What is the problem? Thank you.

# Include
Main ()
{
Float a, B, c, disc, x1, x2, p, q;
Scanf ("a = % f, B = % f, c = % f", & a, & B, & c );
Disc = B * B-4 * a * c;
P =-B/(2 * );
Q = sqrt (disc)/(2 * );
X1 = p + q; x2 = p-q;
Printf ("\ n \ nx1 = % 5.2f \ nx2 = % 5.2f \ n", x1, x2 );
}

Undefined reference to 'sqrt'
Collect2: id returned 1 exit status
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.