Home  >  Article  >  Backend Development  >  Write a program to calculate the perimeter of a decagon in C language

Write a program to calculate the perimeter of a decagon in C language

王林
王林forward
2023-08-27 10:29:051036browse

What is a decagon?

Given the side lengths, the task is to calculate the perimeter of the decagon. A decagon is a polygon with 10 sides, so it is also called a decagon. It has 10 vertices and edges. A regular decagon has equal sides and each interior angle is 144 degrees.

The following is the graphic of a decagon

Write a program to calculate the perimeter of a decagon in C language

There is a formula for calculating the volume and surface area of ​​a truncated cone

Perimeter = 10 * Side

Example

Input-: side=10
Output-: perimeter of Decagon is : 100

Input -: side = 20
Output -: perimeter of Decagon is : 200

Algorithm

Start
Step 1 -> declare function for finding the perimeter
   void perimeter(int n)
      declare variable as int perimeter
      set perimeter=10*n
      print perimeter
step 2 -> In main()
   declare int n=10
   perimeter(n)
Stop

Example

#include <stdio.h>
// Function for finding the perimeter
void perimeter(int n){
   int perimeter;
   perimeter = 10 * n;
   printf("perimeter of Decagon is : %d", perimeter);
}
int main(){
   int n=10;
   perimeter(n);
   return 0;
}

Output

perimeter of Decagon is : 100

The above is the detailed content of Write a program to calculate the perimeter of a decagon in C language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete