将厘米转换为英尺和英寸的程序
给定长度(以厘米为单位)作为输入,任务是将给定长度转换为英尺和英寸
我们可以为此使用长度转换公式-
1 feet = 30.48 cm1 inche = 2.54 cm
示例
Input-: centimetre = 100Output -: Length in meter = 3m
Length in Kilometer = 0.003km
算法
StartStep 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.87Feet is: 0.66
以上是 将厘米转换为英尺和英寸的程序 的全部内容, 来源链接: utcz.com/z/353524.html