roberthsu2003 / cAndC-

48 stars 18 forks source link

BMI的計算 #47

Closed roberthsu2003 closed 1 month ago

roberthsu2003 commented 3 months ago

輸入

輸出

截圖 2024-08-11 中午12 27 19
roberthsu2003 commented 3 months 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 3 months 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 3 months 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 3 months 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 3 months 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 3 months 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;
}
CR7-800 commented 3 months 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;
}