This C++ Program which computes area of circle. The program takes radius of the circle as an input, calculates the area of the circle and outputs it on the screen.
Here is source code of the C++ program which computes area of circle. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C++ Program to Compute the Area of Circle
*/
#include <iostream>
int main()
{
float radius, area;
std::cout << "Enter the radius of circle : ";
std::cin >> radius;
area = 3.14 * radius * radius;
std::cout << "Area of circle with radius "
<< radius << " is " << area;
}
$ g++ main.cpp $ ./a.out Enter the radius of circle : 5 Area of circle with radius 5 is 78.5
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
advertisement
If you wish to look at all C++ Programming examples, go to C++ Programs.
Next Steps:
- Get Free Certificate of Merit in C++ Programming
- Participate in C++ Programming Certification Contest
- Become a Top Ranker in C++ Programming
- Take C++ Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Related Posts:
- Buy Computer Science Books
- Apply for Computer Science Internship
- Apply for C++ Internship
- Practice Programming MCQs
- Practice Computer Science MCQs