اكتب برنامج C يقرأ ثلاث قيم عائمة ويتحقق مما إذا كان من الممكن عمل مثلث منهم. احسب أيضًا محيط المثلث إذا كانت القيم المذكورة صالحة لذلك
- برمجة
- برمجة سي c
- 2021-05-01
- Wassim
الأجوبة
/*Write a C program that reads three floating values and check if it is possible to make a triangle with them. Also calculate the perimeter of the triangle if the said values are valid*/
#include
int main() {
float x, y, z, P, A;
printf("\nInput the first number: ");
scanf("%f", &x);
printf("\nInput the second number: ");
scanf("%f", &y);
printf("\nInput the third number: ");
scanf("%f", &z);
if(x < (y+z) && y < (x+z) && z < (y+x))
{
P = x+y+z;
printf("\nPerimeter = %.1f\n", P);
}
else
{
printf("Not possible to create a triangle..!");
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال