How to debug C Language

Source: Internet
Author: User

The Code branch can better find the cause of the error and modify it.
Note: To Learn programming, you must learn how to debug and troubleshoot the code. Otherwise, it will be hard to do!
Requirement: understand the purpose and skills of debugging. Do not blindly or rely on debugging.
------------------------------------ Task separation line ------------------------------------
Task 2: analyze and design a program, and mark the meaning and purpose of each line of code in the program ;;
Requirements: The program must involve mathematical functions, user-defined functions, selection and repeated control statements, and use the above debugging method to troubleshoot the program;

[Cpp]
# Include <stdio. h>
# Include <math. h>
Int main ()
{
Double c (double a, double B );
While (1)
{
Double a, B;
Printf ("Enter the length of two right-angle sides of the right triangle \ n ");
Scanf_s ("% lf", & a, & B );
If (a> 0 & B> 0)
{
Printf ("the length of the oblique side of the right triangle is % lf \ n", c (a, B ));
}
Else
{
Printf ("the value you entered is incorrect. Please enter it again! \ N ");
}
}
}
Double c (double a, double B)
{
Return sqrt (a * a + B * B); // calculates the oblique edge length.
}

# Include <stdio. h>
# Include <math. h>
Int main ()
{
Double c (double a, double B );
While (1)
{
Double a, B;
Printf ("Enter the length of two right-angle sides of the right triangle \ n ");
Scanf_s ("% lf", & a, & B );
If (a> 0 & B> 0)
{
Printf ("the length of the oblique side of the right triangle is % lf \ n", c (a, B ));
}
Else
{
Printf ("the value you entered is incorrect. Please enter it again! \ N ");
}
}
}
Double c (double a, double B)
{
Return sqrt (a * a + B * B); // calculates the oblique edge length.
}
 

 

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.