Please use code tags when posting your code samples. Here is your program reposted with code tags provided (and formatted).
#include<stdio.h>
#include<conio.h>
float workhrs, overtime, salary, tax, tsalary;
long int rate;
char name[80],choose;
try()
{
clrscr();
textcolor (3);
cprintf("\n How many hours have you been working? ");
scanf("%f",&workhrs);
if(workhrs>=100 && workhrs<=25)
{
printf("\nWORK HOUR is not VALID!");
getch();
try();
}
else
{
textcolor (3);
printf("\n Enter your hourly rate: ");
scanf("%d",&rate);
textcolor (3);
cprintf("\n\n\n Press any key to compute salary...");
getch();
if(workhrs>40)
{
if(workhrs>=40 && workhrs<=50)
{
overtime=workhrs-40;
salary=(40*rate)+(overtime*40);
}
else
{
overtime=workhrs-40;
salary=(rate*40)+(overtime*40)+200;
}
}
else
{
salary=workhrs*rate;
}
clrscr();
if(salary>8000)
{
tax=salary*.15;
tsalary=salary-tax;
textcolor (15);
cprintf("\n Hello %s! Your salary for this month is P%.2f", name, salary);
getch();
clrscr();
gotoxy(1,15);
textcolor (15);
cprintf("\n There is a 15 percent tax deduction which is P%.2f",tax);
getch();
clrscr();
gotoxy(1,15);
printf("\n Your total salary with 15 percent tax deduction is P%.2f",tsalary);
getch();
clrscr();
}
else
{
printf("\n Hello %s %s! Your salary for this month is P%.2f", name, salary);
getch();
}
}
}
main()
{
clrscr();
textcolor (3);
printf("\n Enter name: ");
gets(name);
try();
clrscr();
gotoxy(30,45);
printf("\nWould you like to try again? Y/N\n\n");
scanf("%s",&choose);
if (choose=='y')
main();
else
{
gotoxy(33,11);
textcolor (15);
cprintf("HAVE A NICE DAY!");
getch();
}
}
Some comments:
1) You are using recursion in a manner I believe to be inappropriate. You should be using loops instead of recursion when a user enters an invalid amount of work hours or when the user wishes to repeat the program. In particular, you should never recursively call
main.
2) Don't use
gets. It is dangerous as it does not prevent the user from entering more characters than is possible for the array to hold. You should instead prefer
fgets which allows you to specify the maximum number of characters your buffer can hold.
3) Avoid compiler/OS specific functions wherever possible.
4) Upgrade yourself to a better/newer compiler. Turbo C was around back when most of mankind still lived in caves. There are a number of free ones out there that have been created this millennium.
5)
if(workhrs>40)
{
if(workhrs>=40 && workhrs<=50)
{
overtime=workhrs-40;
salary=(40*rate)+(overtime*40);
}
else
{
overtime=workhrs-40;
salary=(rate*40)+(overtime*40)+200;
}
}
Shouldn't overtime be calculated as
overtime*rate*1.5 (for time-and-a-half).
6)
else
{
printf("\n Hello %s %s! Your salary for this month is P%.2f", name, salary);
getch();
}
Pay attention to how many format specifiers you are using and how many additional arguments you are passing to
printf.