We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I think this is the approach which i think make sense as a begineer....
well i may be wrong xd;)
!!!
int main() {
int a;
int b;
cin>>a>>b;
for ( int i=a ; i<=b;i++ ) {
if(i==1) cout<<"one"<<endl;
else if (i==2) cout<<"two"<<endl;
else if (i==3) cout<<"three"<<endl;
else if (i==4) cout<<"four"<<endl;
else if (i==5) cout<<"five"<<endl;
else if (i==6) cout<<"six"<<endl;
else if (i==7) cout<<"seven"<<endl;
else if (i==8) cout<<"eight"<<endl;
else if (i==9) cout<<"nine"<<endl;
else if (i>9){
if(i%2==0) cout<<"even"<<endl;
else cout<<"odd"<<endl;
}
}
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
For Loop
You are viewing a single comment's thread. Return to all comments →
I think this is the approach which i think make sense as a begineer....
well i may be wrong xd;)
!!!
int main() {
}