My issue
My code
#include <iostream>
using namespace std;
int main() {
int n,a;
cin>>n;
for(int i =0;i<n;i++){
cin>>a;
if(a<=3){
cout<<"BRONZE"<<endl;
}if(3<a>=6){
cout<<"SILVER"<<endl;
}if(a>6){
cout<<"GOLD"<<endl;
}
}
return 0;
}
Problem Link: DOREWARD Problem - CodeChef
@uday_yenke
You have written the second if condition incorrectly.
Instead of writing it like;
if(3<a>=6)
It should have been like;
if((a>3)&&(a<=6)) // if number is either 4, 5 or 6.
You have to separate the conditions and join them via a relational operator in case of having multiple constraints to consider.
Here is my code for reference.
# cook your dish here
for _ in range(int(input())):
x=int(input())
if(x<=3):
print('BRONZE')
elif(x<=6):
print('SILVER')
else:
print('GOLD')