LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-07-2008, 02:12 PM   #1
s_b
LQ Newbie
 
Registered: Oct 2008
Posts: 17

Rep: Reputation: 0
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
 
Old 11-07-2008, 02:34 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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().

Last edited by jschiwal; 11-07-2008 at 06:11 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Top Down programming & Bottom up programming minil Programming 1 06-17-2005 02:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration