将厘米转换为英尺和英寸的程序
给定长度(以厘米为单位)作为输入,任务是将给定长度转换为英尺和英寸
我们可以为此使用长度转换公式-
1 feet = 30.48 cm 1 inche = 2.54 cm
示例
Input-: centimetre = 100 Output -: Length in meter = 3m Length in Kilometer = 0.003km
算法
Start
Step 1 -> Declare function to perform conversion
double convert(int centimeter)
set double inch = 0.3937 * centimetre
set double feet = 0.0328 * centimetre
print inch and feet
Step 2 -> In main()
Declare and set int centimetre=20
Call convert(centimetre)
Stop示例
#include <stdio.h>
// Function to perform conversion
double convert(int centimeter){
double inch = 0.3937 * centimeter;
double feet = 0.0328 * centimeter;
printf ("Inches is: %.2f \n", inch);
printf ("Feet is: %.2f", feet);
return 0;
}
// Driver Code
int main() {
int centimeter = 20;
convert(centimeter);
return 0;
}输出结果
Inches is: 7.87 Feet is: 0.66
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志