my program stops right before the while loop

#include <stdio.h>
int main()
{
	int pay_type_1;
	int overtime;
	int num;
	float commissionsale;
	float payperitem;
	float salary;
	float hourrate;
	const float commissionrate=0.057;
	const float commissionpay=250;
	const float overtimerate=1.5;
	printf("paytype1=Managers salary\n");
	printf("paytype2=hourly worker\n");
	printf("paytype3=commision worker\n");
	printf("paytype4=piece worker\n");
	while (pay_type_1 > 0)
	{
		printf("enter pay type number from above\n (-1 to end)");
		scanf("%d",&pay_type_1);
		switch(pay_type_1)
		{
			case 1:
			printf("Enter manager' fixed salary\n");
			scanf("%f",&salary);
			break;
			case 2:
			printf("Enter hourly rate for paytype two worker\n");
			scanf("%f",&hourrate);
			printf("enter overtime hours worked by the paytype two worker\n");
			scanf("%d",&overtime);
			salary=(hourrate*40)+(overtime*(hourrate*overtime));
			break;
			case 3: 
			printf("enter total sales from paytype three worker\n");
			scanf("%f",&commissionsale);
			salary=commissionpay+(commissionsale*commissionrate);
			break;
			case 4:
			printf("enter nuber of item made by paytype four worker\n");
			scanf("%d",&num);
			printf("enter pay per item\n");
			scanf("%f",&payperitem);
			break;
		}
		printf("Salary:%7.2lf\n",salary);
	}
}

can you see and tell me why its not working. thanks

You are never initializing variable pay_type_1, which is your while loop control variable, so its value is whatever happens to be there from the last time that address was used. If that value happens to be zero or negative, you will never go through that while loop.

Yes I think you need to read paytype from command prompt, ask the user to enter pay type.

This article has been dead for over six months. Start a new discussion instead.