Logo

2.4K views Asked 22 Oct 2019 in Programming
4
Hello Community. I am learning multiples programming languages. I want to find out the area of the circle in C programming, PHP programming, and C# programming languages. How can I get the area of circle these programming languages?
User priyasharma4005 (4.3K Points)

2 Answers
1
shakti (9.4K Points)

answered 22 Oct 2019 (edited)

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); 

    }

}

 


0
vishalrana1 (7.4K Points)

answered 22 Oct 2019 (edited)

Thanks for the question. The solution is very easy. You should understand the basic things to find out the area of the circle using C, PHP, and C# programming languages.

Area of the circle =  π r

The value of the π = 3.14 

r2= r*r; 

You need to create three variables. 

Follow the best solution reference and change according to your need - 

PHP: Add two input box values and sum in the third box

Follow for C# programming 

Mathematics operations in C# programming

Area of the circle in C language - 

#include<stdio.h>
#include<math.h>
main()

{

   float rad=6,9; 

   float p=3.14; 

   float area; 

    area = p*rad*rad;  

    printf("Area of the circle = %.2f\n", area);

}

 


Your Answer
×
Login Required

You must login to continue.

Login Google Login with Google
Register