Skip to main content

Posts

Showing posts with the label Pythagorean. triplet

Check Pythagorean triplet using Matlab

Program We know that the Pythagorean is an equation which satisfies the following condition: a 2  + b 2 = c 2 Write a program with Matlab, which takes the user input of the numbers and checks if the above condition is satisfied. If the condition is satisfied then display the success to the user. Right angle triangle Solution We take the user input and then use the if else statement to check if the user has entered three number which are in accordance to the Pythagorean theorem and display the success using the fprintf in Matlab. Some of the concepts you need to know to solve the above problem are as follows: 1) User input using input function 2) if else statement in Matlab 3) fprintf in Matlab Program 1 2 3 4 5 6 7 8 9 a = input( 'Enter length of Opposite side(a): ' ); b = input( 'Enter the length of Adjacent side(b): ' ); c = input( 'Enter the length of Hypotenuse(c): ' ); if a^ 2 + b^ 2 == c^ 2 fprintf( 'Thats a py...