C++ Examples

C++ Program to Get Excel Column Number in Excel Column Title

The Program in  C++ Program to Get Excel Column Number in Excel Column Title is given below:

#include <iostream>
#include <string>

using namespace std;

int getColumnNumber(string columnTitle) {
  int columnNumber = 0;
  for (int i = 0; i < columnTitle.length(); i++) {
    columnNumber = columnNumber * 26 + (columnTitle[i] - 'A' + 1);
  }
  return columnNumber;
}

int main() {
  string columnTitle;
  cout << "Hello Codeauri Family,enter the Excel column title here to find out the Excel Column Number: ";
  cin >> columnTitle;
  cout << "Okay,the Column number is : " << getColumnNumber(columnTitle) << endl;
  return 0;
}

Output:

Hello Codeauri Family,enter the Excel column title here to find out the Excel Column Number: KP
Okay,the Column number is : 302

Pro-Tips💡

In this program, the getColumnNumber function converts the given Excel column title to its corresponding column number by iterating through each character in the title

and using the ASCII value of the character to calculate the column number.

The main function takes the user input for the Excel column title and outputs the corresponding column number by calling the getColumnNumber function.

Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

Related Posts

C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

C# Program to Delete Element at Desired position From Array

The Program in C# Program to Delete Element at Desired position From Array is given below: Output: Hello Codeauri Family, enter the number of elements in the array:4Enter…

Leave a Reply

Your email address will not be published. Required fields are marked *

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X