Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exercise I'm stuck on.

Status
Not open for further replies.

RWild

Programmer
Nov 14, 2003
53
0
0
US
I posted up here about a week or two ago. Well I've made some progress in my quest to teach myself C. I'm stuck with the following exercise, perhaps stuck may be an understatement. I have NO clue on where to go with this.

IF it's not asking to much would a C VET be kind enough to post the code for this problem up on the boards for me. Thanks in advance for any help.

Description: Write a program that outputs a table with 3 columns(Feet, Feet to Inches, Feet to Meters). The program should display feet from 3 to 30 in there foot increments. The corresponding inches and the corresponding meter equivalents. Use the relationship that 1 meter equals 3.28 feet(Divide the feet by 3.28). Remember 1 foot equals 12 inches. Give your table a descriptive title and column titles.

~Now I know to C VETS this may seem like a simple problem, but I am extremely new to C. Any help would be great! Thanks again guys!

RWild
CMS Technology Dept.
RickyW@CMS-LP.com
 
So...

Do the following for each x from 3 to 30 with increments of 3:
output x, then output x converted from feet to inches, then output x converted from feet to meters, then start a new line.

Seems simple indeed.

You sure you have no clue?
 
Like I said I am extremely new to C, and rather lost.
 
Well, first, if you're getting exercises, I assume you're using a book. (Re)read the chapter/section on for loops in your book.


Then, once you do that, here's your clue (just a rewording of what I said last post):

Code:
for i from 30 to 30 by 3
{
    output x as feet
    output x as inches
    output x as meters
    output newline
}


Which part are you having trouble with, exactly? The logic? The math? The output formatting?
 
Thanks ChipperMDW, I was having trouble with the program in general. I tried many different attempts at it, and have (re)read the chapter a few times. What you gave me is a step in the right direction, and I thank you for that.

If I'm not being too much of a bother would you be able to help me with the wording on the equation for the following:

feet to inches
feet to meters

I can't seem to get a working forumula, yet it's probably something stupid I forget to do.

But thanks again for any help.
 
The exercise you posted clearly gives the conversion factors. In the case of feet to meters, it even gives you directions for performing the conversion. The other should be fairly obvious.

If you're still confused, it's not a problem with being new to C; it's a basic math problem.
 
I know it's a generic match problem BUT like I said I can't get the equation wording right(I get an error, I'm not at my personal PC now, so I can't give you the exact error)

I thank you for your help. Could you please just write down the line for the feet/meter formula.

The inches one I got working, but still a problem with feet to meter conversion.

What would be the formula in C?

I know i'm forgetting something simple and stupid
 
Strangly that's what I have...yet I got an error, maybe the error is somewhere else in the program even though it points to that line.

Thanks for all the Help chipper, sorry if I've been a bother.
 
No problem.

Post the rest of the code and the error; maybe someone can find what the problem is.


As a guess, did you forget the semicolon at the end of the line right before this one?
 
...Sorry for such a late response. I've been rather busy. The strange thing is, I loaded the program up on another computer...and it worked fine.

So...I'm not to sure on what the problem is/was.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top