My programm isn't working - Can somebody provide me a solution ?

My programm isn't working although it complied o.k
I want to calculate taxes for annual salary.
programm code is as follows:

#include <math.h>
#include <stdio.h>

int main()
{

int salary, foros;
printf("Give the yearly salary for which you want tax to be calculated for. \n" );
printf("The salary must take a value between <0......200000>.\n");
printf("Give annual salary:");
scanf("%ld", &salary);

if (salary > 200000 && salary < 0)
printf("Value is out of range. Give value again\n");
printf("salary:\n");
if (salary <= 19500)
foros = 0;

if (salary > 19500 && salary <= 28000)
foros = int((salary-19500)*0.2);

if (salary > 28500 && salary <= 36300)
foros = int((salary - 28000)*0.25+1700);

if (salary > 36300)
foros = int((salary - 36300)*0.3+3775);

printf("Results:\n");
printf("You will have to pay", foros, "euros for tax\n");
scanf("%ld", & salary);
printf("Your tax free salary is", salary-foros,foros, "euros per year\n");
/*printf("\n This corresponds to", salary-foros/12 "euros per month\n");*/

} /* end of main */


Where am i wrong Can anyone help me
What isn't working?

Your printf are lacking of format sequences: http://www.cplusplus.com/reference/clibrary/cstdio/printf/
What do you mean by lacking of format sequences ?
%d, %s etc.
O.K i understand but it seems to me that this part of code doesn't working

f (salary > 200000 && salary < 0)
printf("Value is out of range. Give value again\n");
printf("salary:\n");
if (salary <= 19500)
foros = 0;

if (salary > 19500 && salary <= 28000)
foros = int((salary-19500)*0.2);

if (salary > 28500 && salary <= 36300)
foros = int((salary - 28000)*0.25+1700);

if (salary > 36300)
foros = int((salary - 36300)*0.3+3775);

I think that program stops before command if
I don't know about you but for my compiler it would requre this:

if (salary > 19500 && salary <= 28000)
{
foros = int((salary-19500)*0.2);
}

if (salary > 28500 && salary <= 36300)
{
foros = int((salary - 28000)*0.25+1700);
}

does this help?
also this may be just a typo but you forgot the "i" in "if" in the first line of your code.
C++ doesn't require braces for single lines
closed account (S6k9GNh0)
Just use COUT if you don't feel like using formatting. It's C++ standard anyways....
The OP code looks C
Topic archived. No new replies allowed.