Question

Use nested if to check if a triangle is equilateral, isosceles, or scalene.

Updated on May 31, 2025 | By Learnzy Admin | 👁️ Views: 185 students

Solution
✔ Verified
#include <stdio.h>

int main() {
    int a, b, c;

    printf("Enter three sides of the triangle: ");
    scanf("%d %d %d", &a, &b, &c);

    if (a + b > c && b + c > a && c + a > b) {
        if (a == b && b == c) {
            printf("Equilateral triangle\n");
        } else if (a == b || b == c || a == c) {
            printf("Isosceles triangle\n");
        } else {
            printf("Scalene triangle\n");
        }
    } else {
        printf("Not a valid triangle\n");
    }

    return 0;
}
Was this solution helpful? 25
Click here to download practice questions on If Else Statement

More Questions on If Else Statement

Question 1

Check if a person can vote and also check if they are a senior citizen using nested if.


View solution
Question 2

Find Largest of Three Numbers using nested if


View solution
Question 3

Check if a number is positive, negative, or zero, and even/odd if positive.


View solution
Question 4

How to create BMI (Body Mass Index) Checker in C language ?


View solution
Question 5

Program in C to Check whether a year is a century year or not


View solution
Question 6

Program in C to Find the largest number among three numbers.


View solution
Question 7

Write a program in C to Check whether a character is uppercase or lowercase.


View solution
Question 8

Write a program in C to Check whether a number is divisible by 5 and 11


View solution
Question 9

Program in C to Check the type of character (Alphabet, Digit, Special).


View solution
Question 10

Grading System Based on Marks.


View solution
Question 11

Program in C to Check whether a year is a leap year or not.


View solution
Question 12

Write a program in C to Check if a person is eligible to vote by checking his or her age.


View solution
Question 13

Find the largest of two numbers entered by the user.


View solution
Question 14

Check if a number is positive or negative.


View solution
Question 15

Check if a given Number is Even or Odd.


View solution