首页 计算机相关技术正文

用C赋值语句表示以下计算式 【参考答案】 1)Are

用C赋值语句表示以下计算式

【参考答案】
1)Area=PI*r*r+2*PI*r*h
2)Torque=((2*m1*m2)/(m1+m2))*g
3)Side=sqrt(a*a+b*b-2*a*b*cos(x))
4)Energy=mass(acceleration*height+velocity*velocity/2)
转换成程序:
#include "stdio.h"
#define PI 3.
void main()
{ float r,h,Area;
  printf("Input r:");
  scanf("%f",&r);
  pirntf("Input h:");
  scanf("%f",&h);
  Area=PI*r*r+2*PI*r*h;
  printf("Area=%f",Area);  
}
2)
#include "stdio.h"
#define g 9.8
void main()
{ float m1,m2,Torque;
  printf("Input m1:");
  scanf("%f",&m1);
  pirntf("Input m2:");
  scanf("%f",&m2);
  Torque=((2*m1*m2)/(m1+m2))*g;
  printf("Torque=%f",Torque);  
}
3)
#include "stdio.h"
#include "math.h"
void main()
{ float a,b,c,Side;
  printf("Input a:");
  scanf("%f",&a);
  printf("Input b:");
  scanf("%f",&b);
  printf("Input c:");
  scanf("%f",&c);
  Side=sqrt(a*a+b*b-2*a*b*cos(x));
  printf("Side=%f",Side);  
}
4)
#include "stdio.h"
void main()
{ float mass,acceleration,height,velocity;
  printf("Input mass:");
  scanf("%f",&mass);
  printf("Input acceleration:");
  scanf("%f",&acceleration);
  printf("Input height:");
  scanf("%f",&height);
  printf("Input velocity:");
  scanf("%f",&velocity);   
  Energy=mass(acceleration*height+velocity*velocity/2);
  printf("Energy=%f",Energy);  }






参考答案:
参考解析:正在整理中,欢迎在文下评论区提供答案解析,谢谢!
版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

本文链接:https://scpro.cn/v/63d81685b82411ee.html