# What's wrong with my calculator?

This is a discussion on What's wrong with my calculator? within the C Programming forums, part of the General Programming Boards category; I made a calculator for an economics class that is supposed to decide how much to charge a buyer based ...

1. ## What's wrong with my calculator?

I made a calculator for an economics class that is supposed to decide how much to charge a buyer based on how much you want to profit. For some reason, though, GCC is having issues. In the end, the answer (with a 100 profit target, 300 maintenance, 2/cost of a meatie and veggie burger, and demand of 250 for meatie and 250 for veggie) was -0.027938 dollars. Here's the code:

Code:
```#include <stdio.h>
#include <math.h>

int main(void) {

/* Variables */

float profit;
float demandmeatie;
float demandveggie;

/* Input */

printf("How much of a profit do you want?\n");
scanf("%f",&profit);

//Debugging printf("%f\n",&profit);

printf("How much is your total factory maintenance?\n");

printf("How much does it cost you to produce a Meatie burger?\n");

printf("How much does it cost you to produce a Veggie burger?\n");

printf("How many Meatie burgers does the buyer want?\n");
scanf("%f", &demandmeatie);

printf("How many Veggie burgers does the buyer want?\n");
scanf("%f", &demandveggie);

/* Math */

/* Output */

}```
What's wrong with it?

2. Also, if I comment out the rest and only use the following:

Code:
```#include <stdio.h>
#include <math.h>

int main(void) {

float profit;
float demandmeatie;
float demandveggie;
float producemeatie;
float produceveggie;

printf("How much of a profit do you want?\n");
scanf("%f",&profit);
printf("%f\n",&profit);
}```
It gives me all sorts of numbers for the output (for the input 123): -0.111523, -1.087090... it changes every time I run it. So does codepad.org's compiler.

3. Code:
`printf("The buyer should send you %f dollars\n", &buyercost);`
Lose the & on the buyercost. That's printing the float format of the address of the buyercost variable.

4. Originally Posted by rags_to_riches
Code:
`printf("The buyer should send you %f dollars\n", &buyercost);`
Lose the & on the buyercost. That's printing the float format of the address of the buyercost variable.
That fixed it. Thanks!