LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   need c-programming help (https://www.linuxquestions.org/questions/programming-9/need-c-programming-help-681832/)

s_b 11-07-2008 02:12 PM

need c-programming help
 
I'm trying to write a simple program but it's not working so good so I wonder if anyone has any idea what to do?
How long it takes for a glass of lemonade to reach a temperature in the fridge that makes it possible to drink.
For example:
What's the temperature of your lemonade form the beginning? 25
What temperature are you reaching for? 10
What's the temperature in your fridge? 4

It takes 63 minutes for the lemonade to reach the temperature that u want.
_______________________

dT = ((Tk - Ts) / tau) * dtid
Where Tk is the temperature of the fridge, Ts is the temperature of the lemonade, tau is 50 minutes. dtid is the time the lemonade is in the fridge.



I tried to write the program but I don't think it's right.

/* grandmas.lemonade

int main (){
printf("grandmas lemonade\n");
{

if (lemonades temp'?")
n = 25;
printf(temperature of the lemonade?",n);
{
if (drinking temp'?")
n = 10;
printf("drinking temperature?",n);
{
if (fridgetemp,?")
n = 4;
printf("temperature of the fridge?",n);
{
n = -14,7;
while (((4-25) /50) * 35)! ='\n')

return 0;
}



pleeease can someone help me with this?

thanks

jschiwal 11-07-2008 02:34 PM

You probably want to re-read your into to C book. It doesn't even resemble a C program. Your first mistake is not ending the comment line with */.

The main program is only one line long. The rest after that aren't functions and resemble random garbage.

Define your variables first, and use them in the formula. A C program shouldn't use magic numbers.

Perhaps define the values in main(); write a function that calculates the result and call it from main().


All times are GMT -5. The time now is 11:12 AM.