اكتب برنامج C يأخذ ارتفاع وعرض مستطيل كمدخلات و يطبع محيطه

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

اكتب برنامج C يأخذ ارتفاع وعرض مستطيل كمدخلات و يطبع محيطه

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

Input the height of the Rectangle : 5
Input the width of the Rectangle : 7
Perimeter of the Rectangle is : 24.000000

الأجوبة

/*Write a C program that prints the perimeter of a rectangle to take its height and width as input*/

#include <stdio.h>
int main() {
float rec_width;         /* width of the rectangle */
float rec_height;        /* height of the rectangle */
float rec_perimeter;     /* perimeter (to be computed) */

	printf("Input the height of the Rectangle : ");
	sscanf(line_text, "%f", &rec_height);
	printf("Input the width of the Rectangle : ");
	sscanf(line_text, "%f", &rec_width);
	rec_perimeter = 2.0 * (rec_height + rec_width); /* perimeter = 2 * ( width + height )*/
	printf("Perimeter of the Rectangle is : %f\n", rec_perimeter);
	return 0;
}
هل كان المحتوى مفيد؟

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

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