Click here to Skip to main content
15,884,923 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C++
#include <iostream.h>
using std::cout;
using std::cin;
int main();
{
    int netsalary;
    int basicsalary;
    int bonus;
    int tax;
    cout<<"please enter the basic salary and the bonus";
    cin>>basicsalary;
    cin>>bonus;
    if ( basicsalary<=1000 )
    tax=basicsalary*10/100;
    else tax=basicsalary*20/100;
    netsalary=basicsalary+bonus-tax;
    cout<<netsalary;
    return 0;
}

(enhzflep: code-tags added)
Posted
Updated 13-Nov-13 13:08pm
v2
Comments
Garth J Lancaster 13-Nov-13 18:47pm    
whats the error ? what wouyld you like us to do ?

My best advice is learn how to use the debugger and step through the program inspecting the contents of variables AND/OR learn how to use a logging/tracing framework - doing it this early will save you on complex programs later

Does your Compiler not find the errors ?

There are several of them ...

For example
C#
int main();


No time to comment them all ...

Take a look at this and start reading a book about C++.

C++
#include <iostream>

using namespace std;

int main()
{
int netsalary;
int basicsalary;
int bonus;
int tax;
cout << "please enter the basic salary: ";
cin >> basicsalary;
cout << " and the bonus: ";
cin >> bonus;

if( basicsalary<=1000 )
   tax=basicsalary*10/100;
else
   tax=basicsalary*20/100;

netsalary=basicsalary+bonus-tax;
cout<<netsalary;

return 0;
}


Do you really want calculation with int result ?
 
Share this answer
 
v2
Comments
super 14-Nov-13 9:08am    
IMHO even tax should not be in integer but later float
My solution is based on only the static analyis of your code
1. Intger data types as a result of division oeration result in truncation
2. 2nd input ( or even 1st) values may be corrupted as user may not not know how to differentiate the two inputs ( space,comma etc)
3. Is Negative values accepted?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900