roberthsu2003 / cAndC-

51 stars 17 forks source link

BMI的計算 #47

Open roberthsu2003 opened 1 month ago

roberthsu2003 commented 1 month ago

輸入

輸出

截圖 2024-08-11 中午12 27 19
roberthsu2003 commented 1 month ago

#include <stdio.h>

int main(void) {
  unsigned char myChar = 255;
  printf("myChar:%u\n",myChar);

  //超過數值,溢位
  unsigned char myChar1 = 5000;
  printf("myChar:%u\n",myChar1);

  unsigned short myShort = 60000;
  printf("myShort:%u\n",myShort);

  long long myLong = 2100000000000000000;
  printf("myLong:%lld\n",myLong);
  return 0;
}
catode231 commented 1 month ago
#include <stdio.h>

int main(void) {
  int kg;
  double m, BMI;
  printf("請輸入您的體重(kg):");
  scanf("%d", &kg);
  printf("請輸入您的身高(m):");
  scanf("%lf", &m);
  BMI = (double)kg / (m * m);
  printf("您的BMI為:%.1lf\n", BMI);
  return 0;
}
ching-yu-chen commented 1 month ago
int w,h;
  float bmi,hh;
  printf("身高,體重(身高,體重):");
  scanf("%d,%d",&h,&w);
  hh= h/100.0;
  bmi= w/(hh*hh);
  printf("\nBMI為%f\n",bmi);
  return 0;
AICraig commented 1 month ago

include

int main(void) { int kg; double m, BMI; printf("Please enter your weight in(kg):"); scanf("%d", &kg); printf("Please enter your Height in(m):"); scanf("%lf", &m); BMI = (double)kg / (m * m); printf("Your BMI is:%.2lf\n", BMI); return 0; }

jamduh commented 1 month ago

include

int main(void){ char name[20]; float height; float weight;

printf("請輸入姓名:"); scanf("%s",name);

printf("請輸入身高(cm):"); scanf("%f",&height);

printf("請輸入體重(kg):"); scanf("%f",&weight);

double BMI = weight /(height/100)/(height/100);

printf("%s您好:\n"); printf("您的BMI值為:%.2lf \n",BMI);

return 0; }

TonyWu-Taiwan commented 1 month ago
#include <stdio.h>

int main(void) {
  int hight, weight;
  printf("請輸入身高(公分):");
  scanf("%d", &hight);
  printf("請輸入體重(公斤):");
  scanf("%d", &weight);

  double BMI = weight / (hight / 100.0 * hight / 100.0);
  printf("您的BMI:%.2lf", BMI);

  return 0;
}
wenting1219 commented 4 weeks ago
#include <stdio.h>

int main(void) {
  //輸入身高跟體重,算出BMI值
  double hight, weight, BMI;
  printf("請輸入你的身高(公分):");
  scanf("%lf", &hight);
  printf("請輸入你的體重(公斤):");
  scanf("%lf", &weight);

  BMI = weight / (hight / 100.0 * hight/ 100.0);
  printf("您的BMI為:%.2lf\n", BMI);
  return 0;
}
Benson315-del commented 3 weeks ago
#include <stdio.h>

int main(void) {
  //輸入身高跟體重,算出BMI值
  double hight, weight, BMI;
  printf("請輸入你的身高(公分):");
  scanf("%lf", &hight);
  printf("請輸入你的體重(公斤):");
  scanf("%lf", &weight);

  BMI = weight / (hight / 100.0 * hight/ 100.0);
  printf("您的BMI為:%.2lf\n", BMI);
  return 0;
}
CR7-800 commented 3 weeks ago
#include <stdio.h>
#include <math.h>

int main(void) {
  float h,w,BMI;
  printf("請輸入身高(公分):");
  scanf("%f",&h);
  printf("請輸入體重(公斤):");
  scanf("%f",&w);
  BMI=w/pow(h/100,2);
  printf("BMI=%.2f",BMI);
  return 0;
}