Advertisement
midnight_sun

fixed errors

Mar 25th, 2025
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.17 KB | None | 0 0
  1. #include<stdio.h>
  2. int main() {
  3.     /*
  4.     int age = a;
  5.     float height = h, weight = w;
  6.  
  7.     정수(int)를 담을 수 있는 'age'라는 변수(상자)에 a를 집어 넣는다 -> a가 뭔데?
  8.     실수(float)를 담을 수 있는 'height'라는 변수(상자)에 h를 집어 넣는다 -> h가 뭔데?
  9.     실수(float)를 담을 수 있는 'weight'라는 변수(상자)에 w를 집어 넣는다 -> w가 뭔데?
  10.  
  11.     */
  12.     int age;
  13.     float height, weight;
  14.  
  15.     printf("Enter your age : ");
  16.  
  17.     //scanf("%d", &a); 함수 이름이 age 이므로 &age
  18.     scanf("%d", &age);
  19.  
  20.     printf("Enter your height in cm : ");
  21.  
  22.     //scanf("%f", &h); 함수 이름이 height이므로 &height
  23.     scanf("%f", &height);
  24.  
  25.     printf("Enter your weight in kg : ");
  26.  
  27.     //scanf("%d", %w);
  28.     /*
  29.     * 1. 함수 이름이 weight이므로 &weight
  30.     * 2. %가 아닌 &
  31.     * 3. 실수를 입력 받으므로 %f
  32.     */
  33.  
  34.     scanf("%f", &weight);
  35.  
  36.     //printf(66+(13.8*weight)+)5.0*height-6.8*age);
  37.     /*
  38.     * 1. 실수를 출력할 예정이고, 소수점 둘째 자리까지만 출력해야 하므로 %0.2f를 추가해야함
  39.     * 2. ~~)5.0 -> 괄호 두번
  40.     */
  41.  
  42.     printf("%0.2f", 66 + 13.8 * weight + 5.0 * height - 6.8 * age);
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement