write two functions, one to calculate the area of rectangualar. And the second to calcuate the circumforence of rectangualar.
area=a*b
circumference (a\b)*2
كود PHP:
// تعريف الدول نفس فكرة تعريف المتغيرات
float area(float x, float y);
void circumforence(float x, float y);
int main()
{
float result, a, b;
a = 5;
b = 2.75;
result = area(a, b); //Function1 with return value... بمعنى يستقبل قيمة في المتغير بعد مناداة الدالة وتنفيذها
printf("result = %f", result); // طباعة النتيجة
circumforence(a, b); //Function2 with out return value... فقط يقوم بمناداة الدالة وتنفيذها
}
// float --> يكون نفس نوع متغير result
// area --> function name
// x, y --> يستقبل نسخة من المتغيرين a,b
// طبعا لازم يكون من نفس النوع
float area(float x, float y)
{
float z;
z = x * y;
return z; //ارجاع قيمة للمتغير result
}
// نفس الفكرة لكن تلاحظي وجود
// void
// بدل
// float
// لأن الدالة لا تقوم بإرجاع قيمة
// وبالتالي لا يوجد
// return
// لذلك نطبع النتيجة في نفس الدالة
void circumforence(float x, float y)
{
float z;
z = (x/y) * 2;
printf("result = %f",z); // طباعة النتيجة
}
أتمنى يكون واضح