본문 바로가기
C and C++

[C Examples] 킬로미터(Km)를 마일(Miles)로 변환하기: scaf(), %.f

by Henry Cho 2023. 1. 31.
728x90

킬로미터(Km)를 마일(Miles)로 변환하기: scaf(), %.f

포스트 난이도: HOO_Intern


# Example codes

 

#include <stdio.h>
#include <stdlib.h>

int main()
{
    float miles, distance;

    printf("Enter the distance (in Km): \n");
    scanf("%f", &distance);

    miles= (distance/1.6);

    printf("%.2f Kilometers = %.2f Miles\n", distance, miles);
    
    printf("Posted by HOO.");
    return 0;
}

 

Enter the distance (in Km):
5600
5600.00 Kilometers = 3500.00 Miles
Posted by HOO.

 


 

728x90

댓글