473,394 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Converting the height of a person from feet and inches to centimeters

I am trying to write a program that will convert a height of a person from feet and inches to centimeters. I want to use the relationship: 1 foot = 30.48 cm and 1 inch = 2.54 cm. I am trying to get the output in a form of a table where the left column would contain the height of the person in feet and inches from like 4'5" to 6'5" (with an increment of 1 inch), and the right column will contain the corresponding height in centimeters. The program will perform a conversion with the help of a function: void Conversion (int, int); The function has to be called from the for loop from the function main(). Since there is no return value, each portion of information will be printed inside the function.

Any help with this program would be much appreciated. I am new to the C programming language.
Apr 27 '06 #1
3 25889
Banfa
9,065 Expert Mod 8TB
The general advice I would give is that while people on this forum are willing to help you with your problems very few of us are willing to actually do your homework for you.

Post an attempt at the answer and we will help you sort out the problems.

I suggest as a start you look up

for loops
the printf function with reference to string formating
basic maths operators + - * /
Apr 27 '06 #2
Well, this is what I have so far. I kind of puzzled as to what is the next step I should take? Should I write a for loop?

#include<stdio.h>

int main ()

void Conversion(int feet, int inches) {
int total_inches = 12*feet + inches;
float total_centimeters = 2.54*total_inches;
printf("%d\'%d\" %.0f cm\n", feet, inches, total_centimeters);
}
Apr 28 '06 #3
To clarify from before, all I have is the conversion function. I am puzzled about the main program.

#include<stdio.h>

int main ()
{
int feet = 4;
int inches = 5;
int total_inches = feet + inches;
scanf("%d", total_inches);

for (total_inches = 53; total_inches < 78; total_inches++) {
++total_inches; }
}

void Conversion(int feet, int inches) {
int total_inches = 12*feet + inches;
float total_centimeters = 2.54*total_inches;
printf("%d\'%d\" %.0f cm\n", feet, inches, total_centimeters);
}
Apr 28 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Brent Hoskisson | last post by:
What is a unit of height and width of a form measured as (pixels?) and how can I convert that measurement to inches? Thanks Brent
1
by: SpookyTooth | last post by:
I am trying to write a program that will convert a height of a person from feet and inches to centimeters. I want to use the relationship: 1 foot = 30.48 cm and 1 inch = 2.54 cm. I am trying to get...
4
by: keith | last post by:
I am writing a simple program to convert mm to feet and inches. I have it as follows: #include <stdio.h> #include <math.h> void main() { int x=11; float mm=0; float answer=0;
4
by: onefry | last post by:
Hey I have this prog that i'm working on, starting my first c++ class and kind of a n00b to programming here it is #include <iostream> #include <cstdlib> using namespace std;
7
by: GD1 | last post by:
Dear developers, is there any way I can calculate the height in millimeters of a font at a certain size? Thank you in advance.
6
by: philiprodley | last post by:
Have 3 text boxes. Feet, inches and metres. As I type in feet then inches, I would like to convert this to metres and place the result in the metres text box as soon as I tab on to the next...
3
by: socondc22 | last post by:
Im stuck at this point. The way i was trying to do this was running if statement around my void function and then a else if statement around a different void function but it didnt work... right now...
12
by: Keith G Hicks | last post by:
I have a client that I wrote an MS Access app for quite a few years ago where they need to know the height in inches of a block of text for billing their customers. The MS Access app opens Word in...
2
by: Keith G Hicks | last post by:
I have the following code which runs fine Imports System.Drawing Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button2_Click(ByVal sender As Object, ByVal e As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.