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.
}