Find Excel column number from column title | C ++ program to return title to result of excel sheet . ; Returns resul when we pass title . ; This process is similar to binary - to - decimal conversion ; Driver function
#include <bits/stdc++.h> NEW_LINE using namespace std ; int titleToNumber ( string s ) { int result = 0 ; for ( const auto & c : s ) { result *= 26 ; result += c - ' A ' + 1 ; } return result ; } int main ( ) { cout << titleToNumber ( " CDA " ) << endl ; return 0 ; }