C 語言中將釐米轉換為英尺和英寸的程式
給定以釐米為單位的長度作為輸入,該任務是將給定的長度轉換為英尺和英寸
我們可以使用長度轉換公式 -
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
", 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
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP