#include <stdio.h>

int main() {
    float a = 3/2;   //정수/정수 -> 결과는 정수 -> 결과를 실수 a에 넣음
    float b = 3.0/2; //실수/정수 -> 결과는 실수 -> 결과를 실수 b에 넣음
    int c = (int)b;
    printf("%f   %f    %d\n", a, b, c);
    printf("%7.3f    %7.3f    %3d\n", a, b, c); //7자리중 소숫점 3자리 표현출력
    // %f 계열 소수점 자릿수 제한 출력 -> 남는 소수 부분은 버림이 아니라 반올림해서 출력
    printf("%7.1f %.0f \n", b, b); //소숫점아래 0자리까지 출력->반올림해서 출력/
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: