Home > Backend Development > C++ > body text

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

王林
Release: 2023-08-27 10:29:05
forward
1009 people have browsed it

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
Copy after login

Example

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

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

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
Copy after login

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;
}
Copy after login

Output

perimeter of Decagon is : 100
Copy after login

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!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!