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

String in golang

Arrays in C Language

Literals in Java

Pointers in C Language

Inline V/S Block Level Element

Reserved Words in Java

Identifiers

Data Types in Go language

Printing in C programming

Variable Naming & Scope of Variable