Tech Study

Write C# Program to check whether a triangle can be formed by the given value for the angles

Introduction

Write C# Program to check whether a triangle can be formed by the given value for the angles. I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
public class csharpExercise
{
    static void Main(string[] args)
    {
 
        int anglea, angleb, anglec, sum;
 
       Console.WriteLine("Input three angles of triangle : ");
       anglea = Convert.ToInt32(Console.ReadLine());
       angleb = Convert.ToInt32(Console.ReadLine());
       anglec = Convert.ToInt32(Console.ReadLine());        
 
        // Calculate the sum of all angles of triangle 
        sum = anglea + angleb + anglec;
 
        // Check whether sum=180 then its a valid triangle otherwise invalid triangle
        if (sum == 180)
        {
            Console.WriteLine("It is a valid triangle.\n");
        }
        else
        {
            Console.WriteLine("It is a invalid triangle.\n");
        }  
 
        Console.ReadLine();
    }
}

Result

Write C# Program to check whether a triangle can be formed by the given value for the angles
Write C# Program to check whether a triangle can be formed by the given value for the angles

TaggedWrite C# Program to check whether a triangle can be formed by the given value for the angles

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more