Vyom World.com Let's Touch the Sky Together!
 Home VyomWorld.com Home Free Magazines! VyomLinks.com Home JobsAssist.com Home Vyom Network Contact Us Jobs & Careers Resume Submitter Placement Papers IT Companies Directory Computer Jobs Interview Questions Online Exams Vyom Career eMag. Fun Screensavers New! Send FREE SMS! SMS Jokes Source Codes Library Source Codes Home ASP Source Codes C Source Codes C++ Source Codes COBOL Source Codes Java Source Codes Pascal Source Codes Submit Source Codes GATE GATE an Overview GATE Preparation Study Materal GRE GRE an Overview GRE Questions GRE Preparation GRE Universities TOEFL Preparation TOEFL Resources GMAT Preparation GMAT Resources MBA Preparation MBA Resources Networking Concepts Networking Concepts Testing Preparation Testing Resources Webmasters Free Traffic Builder Webmaster Articles Web Hosting Tutorials Hardware Tutorial 1500 Free eBooks New! FREE Publications
Vyom Career eMag.
 Get 9,000+ Interview Questions & Answers in an eBook. 9,000+ Interview Questions All Questions Answered 5 FREE Bonuses Free Upgrades Get it now!
Get 9,000+ Interview Questions with Answers in an eBook

Home >> Source Codes Library Home >> Language Home >> Category Home > > Item Description
Search Code Library

 Title Progam that gives all details of a Triangle given the lengths of its sides. Author: Adarsh Ramamurthy Visitor Submitted Source Code Author Email: adarsh83@rediffmail.com Description: Gives various details like the angles, whether the triangle can be formed or not, circum radius, etc Hits: 3755 Since 25th November, 2003 Code: Select and Copy the Code #include #include #include #include main() { clrscr(); float a,b,c,S,D,A,B,C,Area,R; printf("Enter the lengths of the three sides of the triangle :\n\n"); scanf("%f%f%f",&a,&b,&c); S = (a+b+c)/2.0; // S is the semiperimeter of the triangle D = S*(S-a)*(S-b)*(S-c);//D is the square of the area of the triangle if(D<=0) { printf("\nThe triangle cannot be formed"); getch(); exit(0); } if((a==b || b==c || c==a) && !(a==b && b==c && c==a)) // this complex logic is to eliminate interpretting a triangle with all three // sides equal as both isosceles and equilateral. printf("\nThe triangle is ISOSCELES\n\n"); if(a==b && b==c && c==a) printf("\nThe triangle is EQUILATERAL\n\n"); if(a!=b && b!=c && c!=a) printf("\nThe triangle is SCALENE\n\n"); Area = sqrt(D); R = (a*b*c)/(4.0*Area); printf("PERIMETER = %.2f units\n",(2.0*S)); printf("AREA = %.2f sq.units\n",Area); printf("CIRCUM RADIUS = %.2f units\n",R); // using sine rule,we get... A = (180.0/3.1415926)*asin(a/(2.0*R));// value of pi should be upto 7 B = (180.0/3.1415926)*asin(b/(2.0*R));// decimal places of accuracy and also C = (180.0/3.1415926)*asin(c/(2.0*R));// note that the 7th decimal place is // 6 and not 7 as it had to be if were if(A==90.0 || B==90.0 || C==90.0) // approximated to 7 decimal places printf("\nThe triangle is RIGHT ANGLED\n"); if(A<90.0 && B<90.0 && C<90.0) printf("\nThe triangle is ACUTE ANGLED\n"); if(A>90.0 || B>90.0 || C>90.0) printf("\nThe triangle is OBTUSE ANGLED\n"); printf("\nThe angles are as follows :\n\n"); printf("A = %.2f degrees\n",A); printf("B = %.2f degrees\n",B); printf("C = %.2f degrees\n",C); printf("\nWhere A,B,C stand for angles opposite to sides %.2f,%.2f,%.2f",a,b,c); printf(" respectively\n"); getch(); return 0; }

ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home