![]() |
|
#1
|
|||
|
|||
First prog, using functions that pass values...Hi guys,
This is my first post as I am a newbie to c... Pardon the ignorance. I am taking my first prog class and I have this assignment: Make a program that contains five functions for the following problem. 1)read depth of a point inside the earth in a function, get_depth() and return it to main 2)Pass depth to function compute_cel() that computes and returns celsius temp at that point using formula: celsius = 18*depth_in_km+20 3)Write another fcn (compute_fahren()) that accepts celsius temp and computes and returns Fahrenheit temp to main. Formula for converting c to f = 1.8*celsius+32 4)Print all three items in a function called print_info(). Remember you have to pass all variable to this function before you can print them. 5)Write top_of_info() function - im fine with this one. Here is what I have, and im just stuck... can anyone point me in a direction where I can at least begin to correct this thing? Thank you so much! Chris CPP / C++ / C Code:
Last edited by LuciWiz : 28-Sep-2005 at 02:22.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#2
|
||||
|
||||
Re: First prog, using functions that pass values...hi..
The function declaration should be of this type: CPP / C++ / C Code:
f(type varname1, type varname2, . . . , type varnameN) In your function compute_cell, you have not defined the parameter list correctly. Hence it should be written as: CPP / C++ / C Code:
CPP / C++ / C Code:
You said: Quote:
CPP / C++ / C Code:
and your compute_cel and compute_fahren functions should be changes as: CPP / C++ / C Code:
Now on to the main function. It should look like: CPP / C++ / C Code:
This link describes about using functions in c Using Functions in C |
|
#3
|
|||
|
|||
Re: First prog, using functions that pass values...Paramesh,
That was MOST helpful, thank you very much! Chris |
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 14:12 |
| Noob question on c arrays and functions | brett | C Programming Language | 1 | 20-Apr-2005 04:59 |
| conflict between printf and stdarg.h va functions | mirizar | C Programming Language | 3 | 12-Jul-2004 09:11 |
| Understanding functions | tommy69 | C Programming Language | 15 | 15-Mar-2004 18:59 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The