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

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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