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

Program to calculate telephone bill

Sum of two numbers in go lang

Program to check a year is leap year or not.

String in golang

Identifiers

Arrays in C Language

Reserved Words in Java

Data types in Java

Pointers in C Language

Literals in Java