Question

In C program #include<stdio.h> Task is to implement the Triangle Program in C. The specification for...

In C program

#include<stdio.h>

Task is to implement the Triangle Program in C. The specification for the program is:

The triangle program accepts three strings, a, b, and c (the sides of a triangle) as command line parameters.

The sides of the triangle must be integers.

The sides a, b, and c must satisfy the following conditions:

c1. 1 ≤ a ≤ 200

c2. 1 ≤ b ≤ 200

c3. 1 ≤ c ≤ 200

c4. a < b + c

c5. b < a + c

c6. c < a + b

The output of the program is the type of triangle determined by the three sides.

The program will output one of these five mutually exclusive outputs:

If all three sides are equal, the program output is "Equilateral".

If exactly one pair of sides is equal, the program output is "Isosceles".

If no pair of sides is equal, the program output is "Scalene".

If any of conditions c4, c5, and c6 is not met, the program output is "Not A Triangle."

If an input value fails any of conditions c1, c2, or c3, the program will output a message like: "Value of b is not in the range of permitted values." The message should be for the first parameter that fails a condition (not all of them).

Program must validate the input and ensure that the proper number of parameters are passed into the main function (if not, print a "usage message" with a.out as the program name).

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

#include<stdio.h>
int main(){
int a,b,c;
printf("Enter three sides of triangle with space seperated integers\n");
scanf("%i%i%i",&a,&b,&c);
if(a<1 || a>200){
printf("Value of a is not in the range of permitted values.\n");
}else if(b<1 || b>200){
printf("Value of b is not in the range of permitted values.\n");

}else if(c<1 || c>200){
printf("Value of c is not in the range of permitted values.\n");
}else{
if(a<b+c && b<a+c && c<a+b){
if( a==b && b==c){
printf("Equilateral\n");
}else if(a==b || b==c || a==c){
printf("Isosceles\n");
}else {
printf("Scalane\n");
}
}else{
printf("Not a traigle\n");
}
}
}

OUTPUT :

PLEASE DO LET ME KNOW IF YOU HAVE ANY QUESTIONS .

THANK YOU

Add a comment
Know the answer?
Add Answer to:
In C program #include<stdio.h> Task is to implement the Triangle Program in C. The specification for...
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
  • Consider again the triangle classification program with a slightly different specification: The program reads floating values...

    Consider again the triangle classification program with a slightly different specification: The program reads floating values from the standard input. The three values A, B, and C are interpreted as representing the lengths of the sides of a triangle. The program then prints a message to the standard output that states whether the triangle, if it can be formed, is scalene, isosceles, equilateral, or right angled. Determine the following for the above program: Part a: For the boundary condition A+B>Ccase...

  • 10. Write a Python program to check if a triangle is equilateral, isosceles or scalene. An...

    10. Write a Python program to check if a triangle is equilateral, isosceles or scalene. An equilateral triangle is a triangle in which all three sides are equal. A scalene triangle is a triangle that has three unequal sides An isosceles triangle is a triangle with (at least) two equal sides

  • It is required to read three real numbers that represent the sides of a possible triangle. For th...

    It is required to read three real numbers that represent the sides of a possible triangle. For the sides to form a triangle, the sum of each pair of sides must be greater than the third side. This has to be fulfilled for each pair of sides. The program must determine the values ​​of the following alphanumeric variables (string type): tria: You will be assigned the value "triangle" if the three real numbers form a triangle or the value of...

  • Answer the questions using the circuit shown a) Capacitor C1 is in  -select- (parallel, series, or neither)...

    Answer the questions using the circuit shown a) Capacitor C1 is in  -select- (parallel, series, or neither) with capacitor C2. (b) Capacitor C4 is in  -select- (series, neither, or parallel) with capacitor C6. (c) Capacitor C1 is in  -select- (series, parallel, or neither) with capacitor C6. (d) Capacitor C3 is in  -select- (parallel, series, or neither) with capacitor C5. (e) Capacitor C4 is in  -select- (parallel neither, or series) with capacitor C5. (f) Capacitor C4 has the same voltage difference as (Select all that apply.)...

  • ***IN PYTHON: Scalene triangle: All sides have different lengths Isosceles triangle: Two sides have the same...

    ***IN PYTHON: Scalene triangle: All sides have different lengths Isosceles triangle: Two sides have the same length Equilateral triangle: All sides are equal Write a program to ask for the length of 3 sides a, b and c. Ask for three sides at a time Determine the type of triangle given three sides Handle all kinds of errors - 1. not integers, int() conversion fails 2. not enough args, 3. too many arguments HINT: use the len() function to check...

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

  • help im alittle lost my teacher posted all this its suppose to be in C++ language....

    help im alittle lost my teacher posted all this its suppose to be in C++ language. can yoh leave comments ans type the code thank you Write a C++ program that accepts the lengths of three sides (a,b,c) of a triangle as input from the user Validate the user input, so that sides a, b, c can only be POSITIVE. The program output should indicate whether or not the triangle is an Equilateral Triangle, a Right Triangle, Isosceles which is...

  • 24. Which of the following transitions in a hydrogen atom would emit the highest energy photon?...

    24. Which of the following transitions in a hydrogen atom would emit the highest energy photon? A n= 2 to n = 1 B. n = 6 to n = 3 C. n = 2 to n = 8 D. n = 1 to n = 2 E. n = 3 to n = 2 25. Identify the hybridization of each carbon atom in the following molecule. (The arrangement of atoms is given; you need to determine how many bonds...

  • (JAVA) Implement a Triangle class. Any triangle can be represented by its THREE sides. Therefore,...

    (JAVA) Implement a Triangle class. Any triangle can be represented by its THREE sides. Therefore, your class will have THREE private member variables → side1, side2 and side3. Use the double data type to represent the triangle sides. In addition, please provide public methods that perform the following FIVE tasks: ▪ An input method that obtains the appropriate values for the three sides from the user. While entering the values of the three sides, please remember the triangle property that...

  • Welcome to the Triangles program Enter length 1: 3 Enter length 2: 5 Enter length 3:...

    Welcome to the Triangles program Enter length 1: 3 Enter length 2: 5 Enter length 3: 5 Enter the base: 5 Enter the height: 8 --------------------- The triangle is Isosceles since it has two equal length sides. Isosceles triangle also has two equal angles The area is: 20 The permimeter is: 13 Continue? (y/n): y Enter length 1: 10 Enter length 2: 10 Enter length 3: 10 Enter the base: 10 Enter the height: 7 --------------------- The triangle is Equilateral...

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