Help me in solving CANDYSTORE problem

My issue

Is there any syntax incorrectly,help will be much appreciated

My code

#include <iostream>
using namespace std;

int main() {
    int T;
    while (T--)
    {
    int X,Y;
    cin>>X>>Y;
    if(Y>X){
        cout<<(X*1+(Y-X)*2)<<'\n';
        }
  
    else{
        cout<<Y*1<<'\n';
        
    }
	return 0;
}
}


Learning course: Basic Math using C++
Problem Link: CodeChef: Practical coding for everyone

include
using namespace std;

int main() {
int T;
cin>>T;
while (T–)
{
int X,Y;
cin>>X>>Y;
if(Y>X){
cout<<(X*1+(Y-X)*2)<<‘\n’;
}

else{
    cout<<Y*1<<'\n';
    
}

}
}

hey you should keep return statement after while loop and another thing to be corrected is you forget to take input T at the beginning.

Thanks seems a very silly mistake thanks

1 Like