VB.Net program to calculate the area of the circle

Here, we are going to learn how to calculate the area of the circle in VB.Net?
Submitted by Nidhi, on November 26, 2020 [Last updated : February 18, 2023]

Calculating the area of the circle

Here we will read the radius from the user and calculate the area of the circle. The formula of the area of the circle is given below:
Area = 3.14 * radius * radius

VB.Net code to calculate the area of the circle

The source code to calculate the area of the circle is given below. The given program is compiled and executed successfully.

'VB.Net program to calculate the area of the circle.

Module Module1

    Sub Main()

        Dim radius As Single = 0.0F
        Dim area As Single = 0.0F

        Console.Write("Enter the radius:")
        radius = Single.Parse(Console.ReadLine())

        area = 3.14F * radius * radius

        Console.WriteLine("Area of Circle: {0}",area)

    End Sub

End Module

Output:

Enter the radius:5.2
Area of Circle: 84.90559
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains the Main() method. In the Main() method we created two local variables radius and area, which are initialized with 0.0F. After that, we read the value of radius from the user.

area = 3.14F * radius * radius

In the above code, we calculated the area of the circle, here we used the value of PI that is "3.14". After that, we printed the value of the area on the console screen.

VB.Net Basic Programs »






Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.