Home »
.Net »
C# Programs
C# program to calculate the size of the area in square-feet based on specified length and width
Given length and height and we have to calculate the size of the area in square-feet using a C# program.
Submitted by Nidhi, on August 18, 2020
Here we will take the length and width of the area as user input and then calculate the size of the area in square feet then print on the console screen.
Program:
The source code to calculate the size of the area in square-feet in C# is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
// Program to calculate the size of the area in
// square-feet based on specified height and width in C#.
using System;
class AreaDemo
{
static int calculateArea(int lengthInFeets, int widthInFeets)
{
return (lengthInFeets * widthInFeets);
}
public static void Main()
{
int lengthInFeets = 0;
int widthInFeets = 0;
int plotArea = 0;
Console.Write("Enter length of the plot in feets: ");
lengthInFeets = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter width of room in feet:");
widthInFeets = Convert.ToInt32(Console.ReadLine());
plotArea = calculateArea(lengthInFeets, widthInFeets);
Console.WriteLine("Plot area is "+plotArea+" square feet");
}
}
Output:
Enter length of the plot in feets: 20
Enter width of room in feet:36
Plot area is 720 square feet
Press any key to continue . . .
C# Basic Programs »