10th Jun 2017, 5:05 PM
Bhuvanesh
Bhuvanesh - avatar
2 Respostas
+ 13
Nice code 👍 My only suggestion would be to use else if like this: if (n==1) { cout<<n<<"st term is "<<b<<endl;} else if (n==2) { cout<<n<<"nd term is "<<b<<endl;} else if (n==3) { cout<<n<<"rd term is "<<b<<endl;} else if (n>3) { cout<<n<<"th term is "<<b<<endl;}
10th Jun 2017, 11:11 PM
Jafca
Jafca - avatar
+ 13
Also, what if n is 21? Your code will say 21th but it should be 21st 😉 These codes may help: https://code.sololearn.com/cvQ0KVguctl5/?ref=app https://code.sololearn.com/wSM8N4d1c14Z/?ref=app
10th Jun 2017, 11:17 PM
Jafca
Jafca - avatar