C Program to Check Triangle is Valid or Not using Angles

C Program to Check Triangle is Valid or Not using Angles

C program to check whether triangle is valid or not if angles are given; Through this tutorial, we will learn how to check whether triangle is valid or not if angles are given in c programs.

Programs and Algorithm to Check Triangle is Valid or Not using Angles

  • Algorithm to Check Triangle is Valid or Not using Angles
  • C Program to Check Triangle is Valid or Not using Angles

Algorithm to Check Triangle is Valid or Not using Angles

Use the following algorithm to write a program to find the third angle of a triangle if two angles are given; as follows:

  1. Take input angles of triangle from user and store it in some variables.
  2. Compute sum of all three angles, store sum in some variables.
  3. Check if(sum == 180) then, triangle can be formed otherwise not.

C Program to Check Triangle is Valid or Not using Angles

/* C Program to Check Triangle is Valid or Not using Angles */
 
#include<stdio.h>
 
int main()
{
	int angle1, angle2, angle3, Sum;
 
  	printf("\n Please Enter Three Angles of a Triangle : ");
  	scanf("%d%d%d", &angle1, &angle2, &angle3);
  	
  	Sum = angle1 + angle2 + angle3;
  	
  	if(Sum == 180)
  	{
  		printf("\n This is a Valid Triangle");
 	}
	else
	{
		printf("\n This is an Invalid Triangle");
	}  
 	return 0;
 }

The output of the above c program; as follows:

Please Enter Three Angles of a Triangle : 90 45 45
This is a Valid Triangle

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *