+ 3
How to decrease token count in c language
I think I have done everything correctly while solving this problem https://prnt.sc/1x8s1sh https://prnt.sc/1x8s4hs https://prnt.sc/1x8s5ci https://prnt.sc/1x8s6es,and this is my code https://code.sololearn.com/c7HnbMWAvY5R how to get token count to 55 from 60
2 Antworten
+ 1
first replace da and hra
sal=basic+(0.8*basic)+(0.4*basic);
I think code wise this is not a improvement, but the goal seems to get rid of some tokens.
second
sal=2.2*basic;
merge 3 instructions in to 1. 1+0.8+0.4 = 2.2
The next user won't have a clue what this factor stands for but it does produces the same result as the previous statement.
last
place the calculation in the printf statement.
printf("%.2f",2.2*basic);
Now you use less tokens.
Please do not consider this as good practice, it make your code hard to maintain.
+ 1
Thank you so much I really learnt a lot from your answer ^_^