Gaming C programming help

Feels Good Man

Well-Known Member
OP
Member
Joined
Apr 15, 2007
Messages
1,640
Trophies
0
Website
Visit site
XP
807
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
0
Website
Visit site
XP
693
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,736
Trophies
2
Age
36
XP
7,423
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
0
Website
Visit site
XP
693
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
  • No one is chatting at the moment.
    OctoAori20 @ OctoAori20: Nice nice-