That's a really great idea if you want to compare three programming languages with the same example. If you want to get the area of the circle using C programming, PHP programming, and C# programming, you should understand the area of a circle formula. The mathematics formula for areal of the circle - A = π r2
π - Pai
The value of π= 3.14
Radius - r
Square of radius - r2
The area of the circle can be written as pai*r*r in C, PHP, and C# programming.
Find the area of the circle in C programming -
C programming is known as the computer programming language. This is the base of all programming languages. If you want to learn any programming language,
you should understand the C language first.
You can find out the area of the circle in C language by creating variables and multiplication.
#include<stdio.h>
#include<math.h>
main()
{
float r=2.0;
float pai=3.14;
float a;
a = pai*r*r;
printf("Area of circle = %.2f\n", a);
}
Execute the above C language example and change the radius of the circle.
Let's find out the area of the circle in PHP.
Area of the circle in PHP programming -
<?php
$pai=3.14;
$r=2.0 ;
$a=$pai*$r*$r;
echo($a);
?>
In PHP, variables are declared with the dollar $ sign.
Get the area of the circle in C# programming -
C# programming is another programming language based on C and C++ concepts. You can find out the area of a circle using the C# language.
public class areaOfCircle{
public static void Main(){
// Your code here!
double pai ,a,r;
pai=3.14;
r=2.0;
a=pai*r*r;
System.Console.WriteLine(a);
}
}