Calculations not working right?

can you guys help me figure out why my program is putting out negative numbers?

here is the program .....

//Knitting for fun

#include <stdio.h>
//contants variables
#define YARDS_IN_HATS 220
#define YARDS_IN_SWEATERS 460

int main(void) {

//variables
int BALLS_OF_YARN, YARDS_IN_BALLS;
int TOTAL_YARDS;
int num_hats, num_sweaters;

//calculate
TOTAL_YARDS = BALLS_OF_YARN*YARDS_IN_BALLS;
num_hats = YARDS_IN_HATS/TOTAL_YARDS;
num_sweaters = YARDS_IN_SWEATERS/TOTAL_YARDS;

//prompt
printf("How many balls of yarn do you have?\n");
scanf("%d", &BALLS_OF_YARN);

printf("How many yards are in each ball?\n");
scanf("%d", &YARDS_IN_BALLS);

printf("you can make %d hats or %d sweaters\n",num_hats, num_sweaters);

system("pause");
return 0;
}

...

.by the way im a very new to c++
You are calculating the results before you get the info from the user. The variables are garbage at that point so you are calculating with garbage.

Also, you seem to be using C, not C++.
thanks for the input , i change it around and seems to works better ...
im still a nub but im using dev c++
Topic archived. No new replies allowed.