Amazon Prime




 
Tagged
  • Flow Chart
  •  

    Circumference of a Circle

    Problem Statement

    1Problem Description :
    2Write Algorithm, Flowchart and Program to Find Circumference of a Circle for which Radius is given.
    3
    4Example 1 :
    5
    6 Input : radius is 4
    7 Output : 25.12
    8 Explanation : Circle Circumference formula is 2 * 3.14 * radius
    9 So circumference = 2 * 3.14 * 4 = 25.12
    10
    11Example 2 :
    12
    13 Input : radius is 5
    14 Output : 31.4
    15 Explanation : Circle Circumference formula is 2 * 3.14 * radius
    16 So circumference = 2 * 3.14 * 5 = 31.4

    Algorithm

    1Input : radius of a circle
    2
    3Step 1: Start
    4Step 2: Read radius
    5Step 3: Calculate Circumference, circumference = 2 * 3.14 * radius
    6Step 4: Print circumference
    7Step 5: Stop
    8
    9Output: circumference

    Flowchart

    Circumference of a Circle - Flowchart

    Code Implementation

    1. Java
    2. C

    1import java.util.Scanner;
    2
    3public class CircumferenceOfACircle {
    4
    5 public static void main(String[] args) {
    6 Scanner sc = new Scanner(System.in);
    7
    8 // Read radius
    9 System.out.print("Enter Radius : ");
    10 float r = sc.nextFloat();
    11
    12 // Calculate Area
    13 double circumference = 2 * Math.PI * r;
    14
    15 // Print area
    16 System.out.printf("Circumference of a circle with radius %f is"
    17 + " %f \n", r, circumference);
    18 }
    19}

    Output 1 :

    1Enter radius : 4
    2Circumference of circle with radius 4.000000 is 25.12
     

    Output 2 :

    1Enter radius : 5
    2Circumference of circle with radius 5.000000 is 31.4
     

  • Flow Chart
  •  
    ...