Created
February 12, 2019 06:31
-
-
Save starhopp3r/a129e770dd89e589b8e2900bd79f91f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++ Program to compute the area of a circle | |
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
int main() | |
{ | |
// Variables to hold the radius and area | |
float radius, area; | |
// Open file | |
ofstream file; | |
file.open("result.txt", ofstream::out | ofstream::app); | |
// Get the radius of the circle from the user | |
cout << "Enter the radius of the circle: "; | |
cin >> radius; | |
// Calculate the area of the cirlce | |
area = 3.14 * radius * radius; | |
// Output | |
cout << "Area of circle with radius " << radius << " is " << area << endl; | |
file << "Area of circle with radius " << radius << " is " << area << endl; | |
// Close the file | |
file.close(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment