السلام عليكــم ورحمـة الله وبركاتــه
انا عندي مشكلة بسيطة في حل هذا البرنامج وان شاء الله اجد الاجابة عندكم
هذا هو السؤال
Write one function that receives the length L and the width W of a rectangle and returns back the perimeter and the area of the rectangle.
(Do not use cout inside the function).
- perimeter = (length + width) * 2
- area = length * width
You have to determine the adequate prototype of the function
المطلوب عمل فنكشن بدون ما استخدم داخلها سي اوت
انا عملت البرنامج بس المشكلة اللي واجهتني كيف اطلع ناتج المحيط والمساحة بدون سي اوت
استخدمت الريترن ولكن الريترن يطلع اما المساحة او المحيط
والبرنامج يطلب مني اخراج المساحة والمحيط معاَ
وهذا هو حلي
#include <iostream>
using namespace std;</SPAN></DIV> <DIV> </DIV> <DIV><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">int fun(int,int);</SPAN></DIV> <DIV> </DIV> <DIV><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">main ()
{
int l,w;
cout<<"enter length and width :\n"
; cin>>l>>w;
cout<<"the perimeter and area : "<<fun(l,w);</SPAN></DIV> <DIV> </DIV><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"> <DIV>
getchar();
getchar();
}</DIV> <DIV> </DIV> <DIV>int fun(int l , int w)
{
int pre,area;
pre=(l+w)*2;
area=l*w;
return pre;
}
