Write a C++ program to check whether a triangle is valid or not, your program should have the following function:

checktriangle(int,int,int)

This function takes the three integer type variables as the angle of three sides. And perform the validity check for the triangle as follows:

A triangle is valid if the sum of all the three angles is equal to 180 degrees.
After performing the validity check function should display the appropriate message i.e. either triangle is valid or not valid.

Sample Output:

Enter the first angle
45
Enter the second angle
45
Enter the third angle
90
valid triangle
Press any key to continue…

I need code of this please any one tell me

How far have you got?

#include<stdio.h>
#include<conio.h>
  main()
{
  int x,y,z,sum=0;
  clrscr();
  printf("\n enter the angles x,y and z");
  scanf("\n %d%d%d",&x,&y,&z);
  checktriangle(x,y,z);
}

 Void checktriangle(int i,int j,int k)
 {

  sum=i+j+k;
  if(sum==180)
{
  printf("\n triangle is valid ");
}
  else
{
  printf("\n triangle is not valid");
}
  return (0);
}

On the downside, that won't compile, and even when the capitalisation of Void is fixed, it still won't compile on any compiler from this side of the mid-nineties. Still ,enough for you to work out a C++ version for yourself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.