My issue
include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t,amt,i;
int arr={0,250000,500000,750000,1000000,1250000,1500000};
float per={0,0.05,0.10,0.15,0.20,0.25,0.30};
cin>>t;
while(t–)
{
cin>>amt;
int or_amt=amt;
for(i=0;or_amt>=arr[i];i++)
{
if(or_amt >= arr[i] && or_amt <= arr[i+1])
{
amt=amt-(or_amt-arr[i])*per[i];
}
else if(or_amt>=arr[i])
{
amt=amt-((250000)*per[i]);
}
}
cout<<amt<<endl;
}
}
say whats the error from the above problem
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t,amt,i;
int arr[]={0,250000,500000,750000,1000000,1250000,1500000};
float per[]={0,0.05,0.10,0.15,0.20,0.25,0.30};
cin>>t;
while(t--)
{
cin>>amt;
int or_amt=amt;
for(i=0;or_amt>=arr[i];i++)
{
if(or_amt >= arr[i] && or_amt <= arr[i+1])
{
amt=amt-(or_amt-arr[i])*per[i];
}
else if(or_amt>=arr[i])
{
amt=amt-((250000)*per[i]);
}
}
cout<<amt<<endl;
}
}
Problem Link: Tax Slabs Practice Coding Problem