473,385 Members | 1,732 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,385 software developers and data experts.

I'm new

Ok so I have this class for C. I have to write this program for my
instructor, where he has already posted the softcopy and algorithm. But
my question is I have to convert meters to feet and in this I have to
output not only the feet but also the inches now I think I have coded
the feet calculation properly but. I don't know how to send the
remainder to inches and than recalculate it and display that
calculation here is what I have coded this so far.

#include <stdio.h>

#define FACTOR 2.54

int main (void)

{

float HM /*hight in meters*/
float INCHES /*hight in inches (later adjust to just inches of
height)*/
float FEET /*whole feet portion of height*/

/*title and credits*/
printf ("Height Converting Program\n");
printf ("Designed by Randolph Gibson - 15 january 2001\n");
printf ("Coded by Rome Baker - September 2005\n\n");

/*explanation*/
printf ("This program will convert a person?s height from meters\n");
printf ("into feet and inches (rounded to the nearest inch) and \n");
printf ("display the result on the screen. The height must be\n");
printf ("entered in metric units and contain decimal portions.\n");
printf ("The andwer will be displayed in whole feet and inches.\n\n");

/*requesting HM*/
printf ("Enter the person?s height in meters:");
scanf ("%f", &HM);

/*claculate and store numbers*/
INCHES = HM * 100 / FACTOR;
FEET = INCHES / 12;

/*display answers*/
printf ("\nThe height is equivilant to %.0f feet and ")

return (0);
}

and here is the page with my instructors algorithm
http://www.gibson.vero-beach.fl.us/c...all/prj02.html

sorry i cant explain this better i am just lost right now

Nov 15 '05 #1
14 2019
"glitter boy" <lo**@nerdshack.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...

You must write the code yourself. If the conversion and rounding aren't
clear, here's example:

h_in_meters = 1.8;

h_in_inches = h_in_meters * 100/*cm per meter*/ / 2.54 /*cm per inch */; /*
< 71 -- round to nearest ((int)(0.5+being_rounded)) when printing as D1 */

h_in_foots = h_in_inches / 12; /* < 6 -- round when printing, if printing as
D2 round down (floor()) */

now to get D3:

h_in_inches2 = h_in_inches - floor(h_in_foots) * 12; /* < 11 -- round to
nearest (as pointed above) when printing as D3 */

HTH,
Alex
Nov 15 '05 #2
Thank you for your help.
I have finished codeing and my code will complie with no errors.
But when I run the program I get a -1 error
Any sugestions?

~Rome

Nov 15 '05 #3
glitter boy wrote:
Ok so I have this class for C. I have to write this program for my
instructor, where he has already posted the softcopy and algorithm. But
my question is I have to convert meters to feet and in this I have to
output not only the feet but also the inches now I think I have coded
the feet calculation properly but. I don't know how to send the
remainder to inches and than recalculate it and display that
calculation here is what I have coded this so far.
[...] float HM /*hight in meters*/
float INCHES /*hight in inches (later adjust to just inches of
height)*/
float FEET /*whole feet portion of height*/


leaving off those semicolons will kill you. It is conventional to use
all uppercase only in naming macros.

Try seeing if you can tell what's happening here:

#include <stdio.h>
#include <math.h>

#define FACTOR 2.54

int main(void)
{

double height_in_meters;
double inch_portion_of_height;

double foot_portion_of_height;
printf("Height Convertion Program\n"
"Designed by Randolph Gibson - 15 january 2001\n"
"Coded by Rome Baker - September 2005\n\n"
"This program will convert a person's height from meters\n"
"into feet and inches (rounded to the nearest inch) and \n"
"display the result on the screen. The height must be\n"
"entered in metric units and contain decimal portions.\n"
"The answer will be displayed in whole feet and "
"inches.\n\n");

do {
printf("Enter the person's height in meters: ");
fflush(stdout);
scanf("%lf", &height_in_meters);
if (height_in_meters <= 0)
printf("We deal only in people with heights > 0.\n");
} while (height_in_meters <= 0);

inch_portion_of_height = height_in_meters * 100 / FACTOR;
foot_portion_of_height = floor(inch_portion_of_height / 12);
inch_portion_of_height -= 12 * foot_portion_of_height;

printf("\nThe height is equivilant to %.0f'%.0f\".\n",
foot_portion_of_height, inch_portion_of_height);

return 0;
}
Nov 15 '05 #4
"glitter boy" <lo**@nerdshack.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Thank you for your help.
I have finished codeing and my code will complie with no errors.
But when I run the program I get a -1 error
Where?
Any sugestions?


What did you return in main()?

Post your code.

Alex
Nov 15 '05 #5

Hi to any students.

THIS is the model of how to ask for help with homework... Ask your
questions this way and you will get help!

In article <11**********************@g43g2000cwa.googlegroups .com>,
glitter boy <lo**@nerdshack.com> writes
Ok so I have this class for C. I have to write this program for my
instructor,
1: clearly saying it is a home work question.
Pretending is it not does not work here. You are also likely to get
answers that, it you use them, will make it obvious that you did not do
the work yourself.
where he has already posted the softcopy and algorithm. But
my question is I have to convert meters to feet and in this I have to
output not only the feet but also the inches
2: clearly state the problem to be solved.
People here are not mind readers. I you can't take the time to properly
explain the problem then no one will take the time to answer.
now I think I have coded
the feet calculation properly but. I don't know how to send the
remainder to inches and than recalculate it and display that
calculation
3: clearly state what you are having a problem with. "It doesn't work"
or similar mean you are lazy and have not analysed the problem . Other
people will not either.

AND

here is what I have coded this so far.

#include <stdio.h>

#define FACTOR 2.54

int main (void)

4: Post your attempt at solving the problem.
No one is going to write code for you but if you have a go they will
point you in the write direction and suggest improvements or point out
the obvious errors

and here is the page with my instructors algorithm
http://www.gibson.vero-beach.fl.us/c...all/prj02.html
5 any additional information.
If people don't get the same information you have one the problem they
could give you the correct answer to a different problem.
sorry i cant explain this better i am just lost right now


6 Be polite. You are asking for help....
Full marks to Glitter Boy for this model question. This is why he has
got some serious and sensible help.

We should post his question to the FAQ as the model how to ask a
homework question.... though most students don't read it :-(


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Nov 15 '05 #6
"Chris Hills" <ch***@phaedsys.org> wrote in message
news:YM**************@phaedsys.demon.co.uk...
Hi to any students.
THIS is the model of how to ask for help with homework... Ask your
questions this way and you will get help!

....
I second that!
And it should not apply to students only, there're guys who aren't students
(yet or already) but they do things the wrong way too. :)

The root of the problem is the blatant consumerism and egoism: people want
to get but not give and often times they fail even to tell what they want
and they fail to be polite enough to get the help they're asking for.
Instead of helping themselves and others to get the problem solved they add
more problems by such a behavior. If they only attempted to put themselves
on the side of the answerers/helpers, they'd start seeing where they're
wrong.

Alex
Nov 15 '05 #7
glitter boy wrote:
Thank you for your help.
I have finished codeing and my code will complie with no errors.
But when I run the program I get a -1 error
Any sugestions?


Yes, post your code so we can actually see what you have done rather
than expecting us to use divination.

Also, tell us *exactly* what input you fed it, *exactly* what output you
got, and what you actually expected.

Finally, please use copy and paste rather than retyping so we don't have
to try and guess what errors are typos and what are the actual errors in
your program.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #8
Chris Hills <ch***@phaedsys.org> writes:
Hi to any students.

THIS is the model of how to ask for help with homework... Ask your
questions this way and you will get help!

In article <11**********************@g43g2000cwa.googlegroups .com>,
glitter boy <lo**@nerdshack.com> writes

[...]
here is what I have coded this so far.

#include <stdio.h>

#define FACTOR 2.54

int main (void)


4: Post your attempt at solving the problem.
No one is going to write code for you but if you have a go they will
point you in the write direction and suggest improvements or point out
the obvious errors


Agreed with one minor caveat: The posted code doesn't compile. If
you're having trouble with the syntax of the language, posting
non-compiling code is ok. If you're having trouble with semantics, or
with an algorithm, take the time to make the code syntactically
correct before posting it, even if it doesn't work. Run it through
the compiler, fix what it complains about, and iterate until the
compiler is happy. It makes it easier for us to help you.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #9
Thank you all for you help with this. I have finished codeing and the
program runs great.
Thank you all again I do truly appreciate all the help.

~Rome

Nov 15 '05 #10
Thank you all for you help with this. I have finished codeing and the
program runs great.
Thank you all again I do truly appreciate all the help.

~Rome

Nov 15 '05 #11
Chris Hills wrote
(in article <YM**************@phaedsys.demon.co.uk>):

Hi to any students.

THIS is the model of how to ask for help with homework... Ask your
questions this way and you will get help!


Alternate method that invariably seems to suck a few people into
answering not-so-cleverly-disguised homework problems for them:

"Hey, I have been wondering for a while if it is possible to
"frob the muffler bearing in C while standing on one leg. This
isn't a homework problem, so spare me. It's just pure
coincidence that I ask a question after years of experience that
only a first semester C student would want to be asking and has
no practical purpose in the universe other than amuse teaching
assistants in lower division courses."

Ahhh, great, not a homework problem. Let's all rush to answer
it. *sigh*

I'm routinely disappointed at how transparent some of the
attempts are, yet folks chime in and cough up pages of code in
response. If they lie enough in the intro, nobody ever says
"but post what you have so far first". Just bear in mind that
in a few years, the software you will be downloading onto your
computer will be written by one of these people that steals
everything they do and has no idea why it works, or even if it
does work at all.

--
Randy Howard (2reply remove FOOBAR)

Nov 15 '05 #12
In article <00*****************************@news.verizon.net> ,
Randy Howard <ra*********@FOOverizonBAR.net> wrote:
....
"Hey, I have been wondering for a while if it is possible to
"frob the muffler bearing in C while standing on one leg. This
isn't a homework problem, so spare me. It's just pure
coincidence that I ask a question after years of experience that
only a first semester C student would want to be asking and has
no practical purpose in the universe other than amuse teaching
assistants in lower division courses."
Very good. Spot on! You've got their number.
Ahhh, great, not a homework problem. Let's all rush to answer
it. *sigh*
You can always reel in a few.
I'm routinely disappointed at how transparent some of the
attempts are, yet folks chime in and cough up pages of code in
response. If they lie enough in the intro, nobody ever says
"but post what you have so far first". Just bear in mind that
in a few years, the software you will be downloading onto your
computer will be written by one of these people that steals
everything they do and has no idea why it works, or even if it
does work at all.


You mean that hasn't happened already?

But yes, it will only get worse.

Nov 15 '05 #13
Kenny McCormack wrote
(in article <dh**********@yin.interaccess.com>):
In article <00*****************************@news.verizon.net> ,
Randy Howard <ra*********@FOOverizonBAR.net> wrote:
...
"Hey, I have been wondering for a while if it is possible to
"frob the muffler bearing in C while standing on one leg. This
isn't a homework problem, so spare me. It's just pure
coincidence that I ask a question after years of experience that
only a first semester C student would want to be asking and has
no practical purpose in the universe other than amuse teaching
assistants in lower division courses."
Very good. Spot on! You've got their number.


Unfortunately.
Ahhh, great, not a homework problem. Let's all rush to answer
it. *sigh*


You can always reel in a few.


I am sometimes surprised at the names included in that set.
I'm routinely disappointed at how transparent some of the
attempts are, yet folks chime in and cough up pages of code in
response. If they lie enough in the intro, nobody ever says
"but post what you have so far first". Just bear in mind that
in a few years, the software you will be downloading onto your
computer will be written by one of these people that steals
everything they do and has no idea why it works, or even if it
does work at all.


You mean that hasn't happened already?


Excellent point. I'm sure it has happened before, simply
because it has been happening here long enough that some of them
may have accidentally discovered a way to pass the final exams
without consulting Usenet for the answers during the test
itself. There has also been enough time for them to be hired
and make it through one or more development cycles before being
fired for incompetence. Windows seems to be the de facto
indicator of its likelihood. :-)
But yes, it will only get worse.


Why contribute to such an undeserving cause? I suspect it has
more to do with flexing the C muscles in front of an admiring
audience than helping the cheating students.

--
Randy Howard (2reply remove FOOBAR)

Nov 15 '05 #14
"Randy Howard" <ra*********@FOOverizonBAR.net> wrote in message
news:00*****************************@news.verizon. net...
Kenny McCormack wrote
(in article <dh**********@yin.interaccess.com>):
In article <00*****************************@news.verizon.net> ,
Randy Howard <ra*********@FOOverizonBAR.net> wrote:
...
"Hey, I have been wondering for a while if it is possible to
"frob the muffler bearing in C while standing on one leg. This
isn't a homework problem, so spare me. It's just pure
coincidence that I ask a question after years of experience that
only a first semester C student would want to be asking and has
no practical purpose in the universe other than amuse teaching
assistants in lower division courses."
Very good. Spot on! You've got their number.


Unfortunately.
Ahhh, great, not a homework problem. Let's all rush to answer
it. *sigh*


You can always reel in a few.


I am sometimes surprised at the names included in that set.


I am, unfortunately, not surprised. It disappoints to see the greats who
do so, and the general excuse is some version of, "There is no stupid
question."

BTW, you don't frob the muffler bearing, you increase entropy in the
muffler housing component. But that is Off Topic in this forum. Here is
a list of Newsgroups that can not only help you re-adjust the muffler
bearing, but show how to...

I'm routinely disappointed at how transparent some of the
attempts are, yet folks chime in and cough up pages of code in
response. If they lie enough in the intro, nobody ever says
"but post what you have so far first". Just bear in mind that
in a few years, the software you will be downloading onto your
computer will be written by one of these people that steals
everything they do and has no idea why it works, or even if it
does work at all.


You mean that hasn't happened already?


It now Outsourced. I assume these "new lands" that are training up a new
batch of bad programmers who ask first, and program second are also the
first recipients of the software they create. At least, I hope so...
I'm sure it has happened before, simply
because it has been happening here long enough that some of them
may have accidentally discovered a way to pass the final exams
without consulting Usenet for the answers during the test
itself.
Hmmm... I remember putting Calculus formulas on my ruler. I guess now
you text-mail yourself the functions to your Treo 700.

Perhaps there is money to be made here (in writing C code [keeping it
topical, people]) writing Palm and PPC programs for cell phones to
enable cheating. It would certainly generate money while ensuring a
future in job security. (Email me - I program Palm!)

There has also been enough time for them to be hired
and make it through one or more development cycles before being
fired for incompetence. Windows seems to be the de facto
indicator of its likelihood. :-)
But yes, it will only get worse.

Everyone wants to be a System Engineer - it used be Liberal Arts. What
ever happened to Liberal Arts?! And why isn't there a Strict Arts
degree. A bit of a miss there!
Why contribute to such an undeserving cause? I suspect it has
more to do with flexing the C muscles in front of an admiring
audience than helping the cheating students.


And that river in Egypt...

--
Mabden
Nov 15 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.