c언어 질문입니다.

글쓴이: 익명 사용자 / 작성시간: 목, 2017/11/30 - 10:15오후
#include
int main()
{
char ch = 'A';
int nData = 15;
float fData1 = 1.5f, fData2 = 3.4f;
printf("%d\n", ch + 2);
printf("%c\n", ch + 2);
printf("%f\n", fData1 * 100 / fData2);
printf("%f\n", fData2 / fData1);
printf("%f\n", nData * 100 / 100);
printf("%f\n", nData / 10 * 100.0f);
printf("%d\n", (int)((float)nData / 10 * 100.0f));
printf("%f\n", (float)nData * 100 / 100);
printf("%f\n", (float)(nData * 100) / 100);
}
이코드의 답이
67
C
44.117646
2.266667
0.000000
100.000000
150
15.000000
15.000000
이건데.....
3번째답은 마지막에5가나오고 5번째답은 4번째답과 똑같이 나와 버리네요.......
맨위에 float를 double로 고치면 3번째답은 고쳐지는데.....5번째답이 문제입니다.
도와주세요....................
Forums:
float double int 미묘한 차이에 관련된
float double int 미묘한 차이에 관련된 문제입니다.
소스 코드는
https://kldp.org/node/158191
참고해서 올려주셔요.
질문할 때는 답할 사람이 답 하기 쉽게 해 주셔요.
https://wiki.kldp.org/wiki.php/DocbookSgml/Beginner_QA-KLDP#AEN70
읽어보셔요.
세벌 https://sebuls.blogspot.kr/
댓글 달기