اكتب برنامج C يقرأ الجانبين المتجاورين وقطر متوازي الأضلاع وتحقق مما إذا كان متوازي الأضلاع مستطيلًا أم معينًا

  • برمجة
  • برمجة سي c

اكتب برنامج C يقرأ الجانبين المتجاورين وقطر متوازي الأضلاع وتحقق مما إذا كان متوازي الأضلاع مستطيلًا أم معينًا

إدخال:

جانبان متجاوران و القطر :

1 <= ai ، bi ، ci <= 1000 ، ai + bi> ci

مثال عن الخرج المتوقع :

Input two adjoined sides of the parallelogram:
3
4

Input the diagonal of the parallelogram:
5

This is a rectangle.

مثال 2 عن الخرج المتوقع :

Input two adjoined sides of the parallelogram:
5
5

Input the diagonal of the parallelogram:
7

This is a rhombus.

الأجوبة

/*Write a C program which reads the two adjoined sides and the diagonal of a parallelogram and check whether the parallelogram is a rectangle or a rhombus*/

#include <stdio.h>
main() {
  int h1, h2, t;
  int rect = 0;
  int hisi = 0;

  rect = 0;
  hisi = 0;
  printf("Input two adjoined sides of the parallelogram:\n");
  scanf("%d", & h1);
  scanf("%d", & h2);
  printf("\nInput the diagonal of the parallelogram:\n");
  scanf("%d", & t);
  if (t * t == h1 * h1 + h2 * h2)
    rect++;
  if (h1 == h2)
    hisi++;

  if (rect > 0)
    printf("\nThis is a rectangle.");
  if (hisi > 0)
    printf("\nThis is a rhombus.");

  return (0);
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...