I debugged your code and found the following issues:
Your scanf
in the main()
method is not reading the due variables. You are reading l1
, l3
and l3
, when you should be reading l1
, l2
, l3
; the consequence of this is that the l2
value (assumed in b
) is not read, and therefore the program is not able to do the checks in the retangulo()
method
Its nested% (which verifies the Pythagorean Theorem) does not have a path in case the condition is false. In other words, the program checks one of the if
, and since the code is in the nested if else if
I mentioned above, it does not have an escape, but to break and exit the method, and it is so the program finishes its execution without printing anything. Therefore, to work around this problem and get the expected verification result, the message "False ..." must be inside the nested if
.
Note: The program will only run the if
that you did there at the end (before else { printf("\n Falso..."); }
) when none of the main()
checks, etc., is true. p>
I'll leave below the fix of your code:
#include<stdio.h>
#include<stdlib.h>
#include<locale.h>
#include<conio.h>
#include<math.h>
int retangulo(int a, int b, int c){
int maior;
if(a>b && a>c){// iníco primeira verificação...
maior = a;
if(pow(maior,2) == pow(b,2) + pow(c,2)){
printf("\n Verdadeiro...");
}
else{
printf("\n Falso...");
}
}// fim primeira verificação...
else if(b > a && b > c){// iníco segunda verificação...
maior = b;
if(pow(maior,2) == pow(a,2) + pow(c,2)){
printf("\n Verdadeiro...");
}
else{
printf("\n Falso...");
}
}// fim segunda verificação...
else if(c > a && c > b){// iníco terceira verificação...
maior = c;
if(pow(maior,2) == pow(a,2) + pow(b,2)){
printf("\n Verdadeiro...");
}
else{
printf("\n Falso...");
}
}// fim terceira verificação...
}
int main(){
setlocale(LC_ALL,"ptb");
int l1, l2, l3, X;
printf("\n Digite quatro valores inteiros:\n");
scanf("%d%d%d", &l1, &l2, &l3);
X = retangulo(l1,l2,l3);
return 0;
}