Help,pls. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

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

12th Apr 2021, 8:04 PM
Артем Попов
Артем Попов - avatar
8 Answers
+ 4
Remove; Console.WriteLine(lenght*height); From the Area method and just return the value. P.S. it is spelled length not lenght
12th Apr 2021, 8:09 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thnx a lot)
12th Apr 2021, 11:30 PM
Артем Попов
Артем Попов - avatar
+ 1
Thanks for the awesome information.
1st Nov 2022, 9:07 AM
Alex Sunny
Alex Sunny - avatar
+ 1
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 ; } } }
12th Jan 2023, 7:42 AM
mustafa Elwakeel
mustafa Elwakeel - avatar
+ 1
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; 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 ; } } }
18th Feb 2023, 3:42 PM
Guy Martial KEYOU
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
14th Dec 2022, 3:17 AM
soumick goswami
soumick goswami - avatar
0
The error is caused by a misspelling in the method parameter. "lenght" should be "length".
31st Jul 2023, 4:50 AM
ATHAVAN M
ATHAVAN M - avatar
0
let width = parseInt(readLine(),10); let length = parseInt(readLine(),10); //Complete the function function area(x,y){ area=length*width; console.log(area); } //call the function area();
21st Oct 2023, 6:37 AM
Shafiya Fathima
Shafiya Fathima - avatar