TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C++

C++ Program to Compute Circumference of a Circle

Overview

In this tutorial, we will write a sample C++ program to compute the Area & Circumference of a Circle. We will use Code::Blocks IDE on the Windows platform.

C++ Code

In this example, we will take the user input for the circle radius, the program computes the area and circumference of the circle, displays the output to the console screen.

 

//Compute area and circumference of circle
#include<iostream>
using namespace std;
const double PI=3.1415;

int main()
{
 double radius=0.0;
 cout << "Enter circle radius :";
 cin >> radius;
 double area= PI*radius*radius;
 double circumference= 2*PI*radius;
 cout << "Area of circle =: " << area << endl;
 cout << "Circumference of circle =: "
 << circumference << endl;
 return 0;
}

Sample output

Run the program and enter sample input. Verify the output of the program.

Enter circle radius :5.0
Area of circle =: 78.5375
Circumference of circle =: 31.415

Screenshot

c++ input

That’s it.

—

The IDE used in the program is Code:: Blocks. To download and install Code Blocks follow the link:
https://www.testingdocs.com/download-and-install-codeblocks/

For more information on Code Blocks IDE, visit the official website of Code blocks IDE:
http://www.codeblocks.org/

 

Related Posts

g not found OpenSuse

C++ /

Install GCC C++ Compiler on OpenSuse

sum of digits c program

C++ /

Sum of Digits of a Number C++ Program

C++ Hello World Program

C++ /

C++ Hello World Program

C++ /

Object-Oriented Programming Language Examples

C++ /

Object-Oriented Programming Features

‹ C++ Output Statement› C++ Variable Declaration

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version