1 / 4

변수의 선언 , 대입문 , 출력문 예

변수의 선언 , 대입문 , 출력문 예. #include < stdio.h >                                           void main()                                                      {                                                           int age; double weight, height, meter;

idola-carr
Download Presentation

변수의 선언 , 대입문 , 출력문 예

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 변수의 선언, 대입문, 출력문 예 #include <stdio.h>                                           void main()                                                      {                                                           intage; double weight, height, meter; age = 21;                               weight = 50.0; height = 163.5; meter = height / 100;                    printf("나의 나이는 %d세 입니다.\n", age);    printf("나의 몸무게는 %f kg 입니다.\n", weight);     printf("나의 키는 %f cm (%f m) 입니다.\n", height, meter); } age에 저장된 값 weight에 저장된 값 meter 에 저장된 값 height에 저장된 값

  2. printf 함수예제 #include <stdio.h> voidmain() { intn1 = 5, n2 = 6, sum; sum = n1 + n2;     printf("*** 연산 결과 ***\n");                                 printf("%d와 %d의 합은 %d입니다.\n", n1, n2, sum); printf("%d와 %d의 평균은 %.2lf입니다.\n", n1, n2, (n1+n2)/2.0); }

  3. 표준 체중 구하기 / 문제 • 자신의 키와 몸무게를 저장한 후 키에 해당하는 표준 체중을 다음과 같이 출력한다. • 참고사항 • 표준체중을 구하는 식: (자신의 키-100) * 0.9 • 1 kg = 2.20459 lb • 1feet = 30.48 cm 변수에저장한 후 출력하는 것이 아니라 printf()에서 식을 작성하여 곧바로 출력하기 키 161cm (5.28 feet) 몸무게: 56.00Kg (123.46 lb) 키 161cm의 표준체중: 54.90Kg height 정수형 %d로 출력 s_weight my_weight(실수형, %.2lf로 출력)

  4. 표준 체중 구하기 / 알고리즘 // 사용할 변수의 선언(int, double) height, my_weight, s_weight // 사용자의 키와 몸무게를대입문을 이용하여 해당 변수에 저장하기 // 저장된 키를 이용하여 그 키에 대한 표준체중 구하기 s_weight= ____________________________; // 결과 출력하기, 출력함수 안에서 피트와파운드 단위 변환하기

More Related