Gaming C programming help

Feels Good Man

Well-Known Member
OP
Member
Joined
Apr 15, 2007
Messages
1,640
Trophies
2
Website
Visit site
XP
857
Country
Canada
CODE#include

main()
{
double factor;
double resizer;
double final;
int end = 1;

printf("RECIPE RESIZER\n");
printf("Enter the factor:");
scanf("%lf", &factor);

while(end ==1)
{
printf("Enter an amount (or 0 to stop):");
scanf("%lf", &resizer);

if (resizer > 0)
{
final = (factor*resizer);
printf("You should use %.2lf instead\n", &final);
}

else if (resizer ==0)
{
printf("Closing program...\n");
end++;
}


//final = 0;

}
system("pause");
}


http://pastebin.com/9gVE5bXJ

Can someone tell me why it doesn't calculate? >__> I have another program with the same problem
 

trumpet-205

Embrace the darkness within
Member
Joined
Jan 14, 2009
Messages
4,363
Trophies
1
Website
Visit site
XP
703
Country
United States
Umm.....

I noticed that you use system("PAUSE") in your programming. You need to include stdlib.h for that function.
You are better off using getchar(), explained in this website: http://www.gidnetwork.com/b-61.html

It has been long time since I done any programming. I'm setting up an IDE right now. I'll run your program and see what is wrong with it.
 

Joe88

[λ]
Global Moderator
Joined
Jan 6, 2008
Messages
12,804
Trophies
2
Age
36
XP
7,834
Country
United States
printf("You should use %.2lf instead\n", &final);

take out the "&" next to final

it works now
 

trumpet-205

Embrace the darkness within
Member
Joined
Jan 14, 2009
Messages
4,363
Trophies
1
Website
Visit site
XP
703
Country
United States
Another thing I want to point out is that you use else if.

"else if" is only used when you have 3 or more conditions. If you have 2 conditions then you use if/else or 2 if.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Veho @ Veho: Looks like America is turning into Iran so it's going to be a difficult decade or so for all...