Also note that we have omitted the minimum field width in the conversion specifications for variables meters Note the use of the escape sequence \” to print a double quote in the output. Take a close look at the last printf statement in this program. Tot_inches =meters * 100.0 I CM_PER_INCH * Convert length in meters to feet and inches */ Finally, the values of feet and inches are printed. It first accepts the value of meters and calculates the values of feet and inches as explained above. Then the length in feet and inches is calculated as follows:Īs the variable feet is of type int, only the integer part of the division tot_inches/12 is assigned to it. Where CM_PER_INCH is a symbolic constant, with a value 2.54, used to represent the centimeters per inch. Tot_inches = meters * 100.0 I CM_PER_INCH To convert the length in meters to the FPS system, we first determine tot_inches, i. Let us also use variable tot_inches of type float to represent the given length in inches. Let us use variable meters of type float to represent length in meters and variables feet and inches of type int and float, respectively, to represent length in the FPS system. Thakur Write a C program to Convert length in meters to feet and inches
#Conio library c menu program full#
%s\n”, fname, mname, lname) Įnter full name (first middle last): Dinesh Kumar ThakurĪbbreviated name: D. Printf(“Enter full name (first middle last): “) * Write person’s name in abbreviated form */Ĭhar fname, mname, lname /* person’s name */ The initial letters of fname and mname are printed using fname and mname, respectively. Then the name is printed in the desired abbreviated form using a printf function. e., values of fname, mname and lname using a scanf function. The program given below first accepts the full name, i. Let us use character arrays fname, mname and lname to store the first name, middle name and last name of a person.