C Tutorial
This c program is used to calculate the perimeter of a triangle based on user inputs each side lengths length1, length2 and length3.
Perimeter of a triangle: length1 + length2 + length3 length1, length2 and length3 are length of each sides of triangle.
// Finds perimeter of a triangle #include<stdio.h> void main() { int length1, length2, length3, perimeter=0; printf("\nFinds perimeter of a triangle\n------------------------"); printf("\nEnter Length1: "); scanf("%d", &length1); printf("\nEnter Length2: "); scanf("%d", &length2); printf("\nEnter Length3: "); scanf("%d", &length3); perimeter = length1+length2+length3; printf("Perimeter of a triangle is: %d", perimeter); }
Output:
$ cc perimeter-of-triangle.c $ ./a.out Finds perimeter of a triangle ------------------------ Enter Length1: 5 Enter Length2: 7 Enter Length3: 9 Perimeter of a triangle is: 21[
C Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page