printf("ho_tari\n");

fahr2celsius 본문

C

fahr2celsius

호타리 2023. 8. 31. 15:04
#include <stdio.h>

int main(void)
{

	int fahr;

	int celsius;

	fahr = 100;

	//celsius = 5/9 * (fahr - 32);

	//celsius = 5.0 / 9.0 * (fahr - 32);

	celsius = (fahr - 32) * 5/9;

	printf("fahr : %d ---> celsius : %d\n", fahr, celsius);

	return 0;

}

 

<compile 결과>

 

<fahr2celsius2.c>

#include <stdio.h>



int main(void)

{

	int fahr;

	double celsius;

	

	printf("Fahrenheit : ");

	scanf("%d", &fahr);

	celsius = 5.0 / 9.0 * (fahr - 32);

	

	printf("Celsius : %.3f\n", celsius);

	

	return 0;

}

 

<compile 결과>

'C' 카테고리의 다른 글

findValue  (0) 2023.09.01
findMax  (0) 2023.09.01
factorial  (0) 2023.08.31
dice  (0) 2023.08.31
compareOp  (0) 2023.08.31