• Register
Welcome to Techno Smarter QA, Questions, Answers Community
Welcome to Techno Smarter Q&A, where you can ask questions and receive answers from other members of the community. Ask the tech & programming Question that you want. Guests Posting are allowed.
+4 votes
30 views
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?
in Programming by (3.1k points) 1 13 37

2 Answers

+1 vote

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 circle - A = π r2  

π - Pai 

The value of π= 3.14 

Radius - r 

Square of radius - r2

The area of 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 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); 

    }

}

by (7.1k points) 4 20 46
edited by
0 votes

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

   

  

}

by (5.1k points) 4 15 45
...