How to decrease token count in c language | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

24th Oct 2021, 4:35 PM
morgan
morgan - avatar
2 Answers
+ 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.
24th Oct 2021, 6:31 PM
sneeze
sneeze - avatar
+ 1
Thank you so much I really learnt a lot from your answer ^_^
25th Oct 2021, 2:19 AM
morgan
morgan - avatar