Write a program in C to check whether a triangle is valid or not, when the three angles of the triangle is entered through the keyboard. A triangle is valid if the sum of all the angles is equal to 180 degrees.
#include <stdio.h>
#include <conio.h>
void main() {
int a,b,c,d;
clrscr();
printf("Enter the angles of triangle : ");
printf("\nFirst : ");
scanf("%d", &a);
printf("Second : ");
scanf("%d", &b);
printf("Third : ");
scanf("%d", &c);
d=a+b+c;
if(d==180){
printf("\nThis is a VALID triangle");
} else {
printf("\nThis ia NOT a VALID triangle");
}
getch();
}
#include <conio.h>
void main() {
int a,b,c,d;
clrscr();
printf("Enter the angles of triangle : ");
printf("\nFirst : ");
scanf("%d", &a);
printf("Second : ");
scanf("%d", &b);
printf("Third : ");
scanf("%d", &c);
d=a+b+c;
if(d==180){
printf("\nThis is a VALID triangle");
} else {
printf("\nThis ia NOT a VALID triangle");
}
getch();
}
Post a Comment