ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to calculate the area of the rectangle

Here, we are going to learn how to calculate the area of the rectangle in VB.Net?
Submitted by Nidhi, on November 26, 2020

Here, we will read the value length and breadth of the rectangle from the user and then calculate the area of the rectangle. The formula of the area of the rectangle is given below:
Area = length * breadth

Program/Source Code:

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

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

Module Module1

    Sub Main()

        Dim length As Single = 0.0F
        Dim breadth As Single = 0.0F
        Dim area As Single = 0.0F

        Console.Write("Enter the length of rectangle: ")
        length = Single.Parse(Console.ReadLine())

        Console.Write("Enter the breadth of rectangle: ")
        breadth = Single.Parse(Console.ReadLine())

        area = length * breadth

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

    End Sub

End Module

Output:

Enter the length of rectangle: 19
Enter the breadth of rectangle: 3.2
Area of rectangle: 60.8
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 three local variables length, breadth, and area that are initialized with 0.0F . After that, we read the value of length and breadth from the user.

area = length * breadth 

Here, we calculated the area of the rectangle, and then we printed the value of the area on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.