Circumference of a Circle
Problem Statement
1Problem Description :2Write Algorithm, Flowchart and Program to Find Circumference of a Circle for which Radius is given.34Example 1 :56 Input : radius is 47 Output : 25.128 Explanation : Circle Circumference formula is 2 * 3.14 * radius9 So circumference = 2 * 3.14 * 4 = 25.121011Example 2 :1213 Input : radius is 514 Output : 31.415 Explanation : Circle Circumference formula is 2 * 3.14 * radius16 So circumference = 2 * 3.14 * 5 = 31.4
Algorithm
1Input : radius of a circle23Step 1: Start4Step 2: Read radius5Step 3: Calculate Circumference, circumference = 2 * 3.14 * radius6Step 4: Print circumference7Step 5: Stop89Output: circumference
Flowchart
Code Implementation
- Java
- C
1import java.util.Scanner;23public class CircumferenceOfACircle {45 public static void main(String[] args) {6 Scanner sc = new Scanner(System.in);78 // Read radius9 System.out.print("Enter Radius : ");10 float r = sc.nextFloat();1112 // Calculate Area13 double circumference = 2 * Math.PI * r;1415 // Print area16 System.out.printf("Circumference of a circle with radius %f is"17 + " %f \n", r, circumference);18 }19}
Output 1 :
1Enter radius : 42Circumference of circle with radius 4.000000 is 25.12
Output 2 :
1Enter radius : 52Circumference of circle with radius 5.000000 is 31.4