Consider the code below: include<stdio.h> ; int PYTH_TRIPPLE( int A, int B, int
ID: 3773657 • Letter: C
Question
Consider the code below: include<stdio.h> ; int PYTH_TRIPPLE( int A, int B, int C) { return (C*C = A*A + B*B) } main() { int a, b, c; printf(" insert a, b och c: "); scanf("%d %d %d", a, b, c); if(pyth_tripple(a,b,c)) printf("Pythagoran tripple. "); else printf("Not pythagoran tripple. "); return 0; }This code is to proof if three numbers , a, b and c and c*c = a*a + b*b is a pythogoran tripple. where a,b,c are the sides of a right angle triangle. But this code has many errors. Find the errors and correct them. An example of a Pythagoran tripple for 3, 4 och 5 is: 5*5 = 4*4 + 3*3.
Explanation / Answer
#include <stdio.h>
#include <conio.h>
bool pyth_tripple( int A, int B, int C)
{
if(C*C == A*A + B*B)
return true;
return false;
}
void main()
{
int a, b, c;
printf("Insert a, b and c: ");
scanf("%d %d %d", &a, &b, &c);
if(pyth_tripple(a,b,c))
printf("Given numbers are pythagoran tripple. ");
else
printf("Given numbers are not pythagoran tripple. ");
getch();
}
Output:
Insert a, b and c: 3 4 5
Given numbers are pythagoran tripple.