Question

Second Program: triples.c 8. Create a program named triples.c C How to Program, 8th edition, problem 4.27 on page 154. In o

to be done in c language. follow prompt

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Learner,

Here is the code for your solution,

#include<stdio.h>
#include<conio.h>
main()
{
   int side1,side2,hypotenuse;                                        //Declaring the variables side1 side2 and hypotenuse
   int i,j,k;                                                            //Declaring the iterating variables
   printf("side1 side2 hypotenuse\n");                                // These two lines
   printf("----- ----- ----------\n");                                // are printed for formatting the output
   for(side1=1;side1<10;i++)                                           // First loop for the first side
   {  
       for(side2=side1;side2<10;j++)                                   //The second nested loop is for side2. NOTE that it starts from the value
       {                                                               // of side1 in order to reduce the number of cycles
           for(hypotenuse=side2;k<10;j++)                           //This loop is to find the hypotenuse
           {
               if(hypotenuse*hypotenuse == side1*side1 + side2*side2)   //Checking if the third side satisfies the hypotenuse relation
               {
               printf("%d\t\t%d\t\t%d\n",side1,side2,hypotenuse);           // printing the values if true
               }

           }
       }
   }
}

CORRESONDING OUTPUT:

I have shown first and ending part of the printed values.

side1 side2 hypotenuse 113 ad 65 14 145 3e 18e 181 52 ១១ 181 35 15 128 264 122 15 6e 65 312 168 313 178 45 123 365 - ៖ – ១៩ 1

580 609 841 580 741 941 582 776 970 585 648 873 585 780 975 588 784 980 591 788 985 594 608 850 594 792 990 595 600 845 597 7

I hope I have explained the question the way you were expecting. If you still have any doubts or want any other explanation, feel free to ask us in the comment section.

Please leave a like if this was helpful.

Thanks,

Happy Studying.

Add a comment
Know the answer?
Add Answer to:
to be done in c language. follow prompt Second Program: triples.c 8. Create a program named...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please use only C language and NOT C++ or Java You are now allowed to use...

    Please use only C language and NOT C++ or Java You are now allowed to use the following • for loops • math.h and pow() function • formatting float and double numbers • switch statements • getchar() function • ASCII chart • do…while loops • break and continue statements • Logical AND (&&), logical OR (||), logical NOT (!) operators Pythagorean triples are three positive integer numbers a, b, c that form the sides of a right triangle, such that...

  • Write the java program: A right triangle can have sides whose lengths are all integers. The...

    Write the java program: A right triangle can have sides whose lengths are all integers. The set of three integer values for the length of the sides of a triangle is called a Pythagorean triple. The length of the three sides must satisfy the relationship that the sum of the squares of the sides is equal to the square of the hypotenuse. Write a Java application that prompts the user for an integer that represents the largest side value and...

  • C code. Write a program to find all the triangles with integer side lengths and a...

    C code. Write a program to find all the triangles with integer side lengths and a user specified perimeter. Perimeter is the sum of all the sides of the triangle. Integers a, b and c form a triangle if the sum of the lengths of any two sides is greater than the third side. Your program should find all the triples a, b and c where a + b + c is user specified perimeter value. Print each triple only...

  • PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP...

    PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP AND FORMAT: #include <iostream> using namespace std; int main() { //variables here    do { // program here             }while (true);    } Objectives To learn to code, compile and run a program containing SELECTION structures Assignment Write an interactive C++.program to have a user input the length of three sides of a triangle. Allow the user to enter the sides...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT