# Rank of a word

A few days back i had posted a question if it is possible to find the rank of a word. Many gave me answers and some even codes, but i just couldnt accept that basically means i am copying their codes. Which is why I tried my own way, but unfortunately it isnt working. I have briefed my problem as much as possible, so please could someone help me out with this one? Below you will find how to find the rank of a word, and my code as well, and i have added single line comments to explain why i have added that part of the code. The out put is displaying only 1. which means the whole rank function(of my program) isnt working. What is Rank? ____________________________________________________________________ EX, factorial of 5 is , 5! = 5 x 4 x 3x 2 x 1 =120, Now the question would be find the dictionary rank of the word LIFT ANS First of all arrange in alphabetical order, F I L T Now no of words beginning with F (I,L,T) - 3! = 6 no of words beginning with I (F,L,T) - 3! = 6 since L is the first letter of the word whose rank is what we are concerned L is locked and the our second unknown letter will be F L x x x No of words beginning with F = 2! = 2 I is the second letter of the word whose rank is what we are concerned so I is also locked L I x x if proceed in the original order the subsequent letter is F, so lock F L I F x Next letter finally turns out to be T L I F T. so add total = 6 + 6+ 2 = 14 as lift is also a word we need to consider that too 14 + 1 = 15. Rank of lift is 15. Using the same method i have written a code. so Here it is: https://code.sololearn.com/cpsCsyYGhGSu/#cpp