Following is the program to check whether triangle is valid or not :-
#include<stdio.h>
int main()
{
int a,b,c,sum;
clrscr();
printf("enter three angles of triangle\n");
scanf("%d%d%d",&a,&b,&c);
sum=a+b+c;
if(sum==180)
{
printf("triangle is valid");
}
else
{
printf("triangle is not valid");
}
return 0;
}
Output:-
#include<stdio.h>
int main()
{
int a,b,c,sum;
clrscr();
printf("enter three angles of triangle\n");
scanf("%d%d%d",&a,&b,&c);
sum=a+b+c;
if(sum==180)
{
printf("triangle is valid");
}
else
{
printf("triangle is not valid");
}
return 0;
}
Output:-
Note- using the same logic we can design this program in C++ too
No comments:
Post a Comment