Area of Circle

area of circle

C Programming

#include<stdio.h>
#define PI 3.14156
int main() {
    float r,area;
   
    printf("Enter the radius: ");
    scanf("%f",&r);
   
    area = PI * r * r;
   
    printf("Simple interest = %.2f",area);
    return 0;
}

C++ Programming

#include<iostream>
#define PI 3.14156

using namespace std
int main() {
    float r,area;
   
    cout<<"Enter the radius: ";
    cin>>r;
   
    area = PI * r * r;
   
    cout << "Area of circle = "<<area<<endl;
   
    return 0;
}

Java

import java.util.Scanner;

class CircleArea {
    public static void main(String args[]) {
        final float PI = 3.14156f;
       
        float r,area;
       
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter the radius: ");
        r = sc.nextFloat();
       
        area = PI * r * r;
       
        System.out.println("Area of circle = "+area);
    }
}

Go Lang

package main
import "fmt"

func main() {
    const PI = 3.14156
    var r float64
    fmt.Print("Enter the radius: ")
    fmt.Scan(&r)
   
    area := PI * r * r
   
    fmt.Print("Area of circle = ",area)
}

PHP

<?php
    define('PI',3.14156);
   
    if(isset($_POST['sub'])) {
        $r = $_POST['r'];
        $area = PI * $r * $r;
       
        echo "Area of circle = ".$area;
    }
?>

Comments

Popular posts from this blog

Overview of Go lang

Arrays in C Language

Data Types in Go language

Creating your first html page

Say Hello world in Go lang

Arrays in Go lang

Installing go lang

String in golang

Decision Making in Go lang

Decision Making Statements