// i dont know where i am getting wrong..the answer is contniously zero...plz help me
#include<iostream>
#include<cstdlib>
using namespace std;
int rand_val()
{
return rand()%1000000+10000;
}
int main()
{
int i,j;
int salary_vec[100]={};
for( i=0;i<100;i++)
{
salary_vec[j]=rand_val();
}
double tax_vec[100]={};
for( j=0;j<100;j++)
{
if(salary_vec[i]>=70000)
{
tax_vec[j]=salary_vec[i]*(10/100);
}
else if((salary_vec[i]>=50000)&&(salary_vec[i]<70000))
{
tax_vec[j]=salary_vec[i]*(7.5/100);
}
else if((salary_vec[i]>=30000)&&(salary_vec[i]<50000))
{
tax_vec[j]=salary_vec[i]*(5/100);
}
cout<<tax_vec[j]<<endl;
}
return 0;
}
muhammad.khan.3576
0
Newbie Poster
Recommended Answers
Jump to Postreturn rand()%1000000+10000;
What is the maximum value
rand()
will return?
What is the remainder of that value and %1000000 ?
Jump to PostThink about what WaltP said. If the result is always zero, then none of the if statements are true. You never get a value greater than or equal to 70,000 or 50,000 or 30,000.
All 6 Replies
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
dx9_programmer
12
Newbie Poster
muhammad.khan.3576
0
Newbie Poster
ravenous
266
Posting Pro in Training
dx9_programmer
12
Newbie Poster
muhammad.khan.3576
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.