+ 2
Help,pls.
You are writing a program to calculate the area of a rectangle. Currently it takes the the length and the height as inputs. Complete the given method to take them as arguments, then calculate and return the area. Sample Input 4 5 Sample Output 20 Code: using System; using System.Formats.Asn1; namespace площадь_прямоугольника { class Program { static void Main(string[] args) { int lenght = Convert.ToInt32(Console.ReadLine()); int height = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(Area(lenght,height)); } static int Area(int lenght, int height) { Console.WriteLine(length*height); return length*height; } } }
7 Answers
+ 4
Remove;
Console.WriteLine(lenght*height);
From the Area method and just return the value.
P.S. it is spelled length not lenght
+ 1
Thnx a lot)
0
Thanks for the awesome information.
0
Area of a Rectangle
Create a function that calculates the area of a rectangle. If the arguments are invalid, your function must return -1. Examples area(3, 4) ➞ 12 area(10, 11) ➞ 110 area(-1, 5) ➞ -1 area(0, 2) ➞ -1 Notes N/A
algebrageometrymath
Very Easy
0
Create a function that calculates the area of a rectangle.
0
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int length = Convert.ToInt32(Console.ReadLine());
int height = Convert.ToInt32(Console.ReadLine());
//Output
Console.WriteLine (Area(length , height)) ;
}
//complete the method
static int Area (int length, int height)
{
return length* height ;
}
}
}
0
I will try to figure it out for more.
Hot today
What’s wrong?
3 Votes
Question is write a c program to print prime numbers up to n and print the largest number in array.
1 Votes
Error in Program
1 Votes
SQL
1 Votes
While loop
0 Votes