แบบฝึกหัดที่ 9

จงแปลงนิพจน์ทางคณิตศาสตร์ต่อไป​นี้ เป็นโปรแกรมที่จะรับค่า a,b,cจากแป้นพิมพ์ แล้วคำนวณหาค่า d จาก d = 1+[(2a+5b)/(c-5)(c+8)] (ข้อแนะนำ : ใช้ตัวแปรชนิด float เพื่อเก็บค่าที่ใช้คำนวณ) 

วิธีทำ

#include<stdio.h>
int main(void)
{
float a,b,c,d;
printf("Input a = ");
scanf("%f",&a);
printf("Input b = ");
scanf("%f",&b);
printf("Input c = ");
scanf("%f",&c);
d=1+((2*a+5*b)/((c-5)*(c+8)));
printf(" result = %f",d);
return 0;
}

6 ความคิดเห็น: