Brijmohan lal Sahu - Facebook
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Saturday, November 8, 2014

Program to take three sides of triangle as input and verify whether the triangle is an isosceles,scalene or an equilateral triangle in C.


Triangle type


Code Box
---------------------------------------------

/*Program to take three sides of triangle as input and verify whether the triangle is an isosceles,scalene or an equilateral triangle */

#include<stdio.h>
#include<conio.h>

void main()
{
int side1,side2,side3;
clrscr();
printf("\nEnter sides of triangle:");
printf("\nSise1 :");
scanf("%d",&side1);

printf("\nSide2 :");
scanf("%d",&side2);

printf("\nSide3 :");
scanf("%d",&side3);


if(side1==side2 && side2==side3)
{
printf("\nEquilateral");
}
else
if(side1==side2 || side2==side3 || side3==side1)
{
printf("\nIsosceles");
}
else
{
printf("\nScalene");
}

getch();
}



---------------------------------------------

possible way 2



Code Box 2
---------------------------------------------

/*Program to take three sides of triangle as input and verify whether the triangle is an isosceles,scalene or an equilateral triangle */

#include<stdio.h>
#include<conio.h>

void main()
{
int side1,side2,side3;
clrscr();
printf("\nEnter sides of triangle:");
printf("\nSise1 :");
scanf("%d",&side1);

printf("\nSide2 :");
scanf("%d",&side2);

printf("\nSide3 :");
scanf("%d",&side3);

if(side1==0 || side2==0 || side3==0)
{
printf("\nTriangle not possible");
goto next;

}


if(side1==side2 && side2==side3)
{
printf("\nEquilateral");
}
else
if(side1==side2 || side2==side3 || side3==side1)
{
printf("\nIsosceles");
}
else
{
printf("\nScalene");
}
next:

getch();
}







No comments: