Skip to content

Instantly share code, notes, and snippets.

@IvanNikolov
Created October 7, 2014 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IvanNikolov/8ba97d4ebfe49314f51e to your computer and use it in GitHub Desktop.
Save IvanNikolov/8ba97d4ebfe49314f51e to your computer and use it in GitHub Desktop.
using System;
//Write a program that reads the radius r of a circle and prints its
//perimeter and area formatted with 2 digits after the decimal point.
//Examples:
//r perimeter area
//2 12.57 12.57
//3.5 21.99 38.48
class CirclePerimeterAndArea
{
static void Main()
{
double r = double.Parse(Console.ReadLine());
double pi = 3.142;
double area = pi * (2*r);
double perimeter = 2 * pi * r;
Console.WriteLine("Area: {0:f2}\nPerimeter: {1:f2}", area, perimeter);
//OR?
// Console.WriteLine("Area: {0:0.00}\nPerimeter: {1:0.00}",area, perimeter);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment