C++ Program to Determine the Unicode Code Point at a Given Index
Here, we will find out the unicode code point at a given index using a C++ program.
Input:
arr = "geEKs"
Output:
The Unicode Code Point At 0 is = 71.
The Unicode Code Point At 1 is = 101.
The Unicode Code Point At 2 is = 69.
The Unicode Code Point At 3 is = 107.
The Unicode Code Point At 4 is = 83.
Approach:
If the array/string value is increased then it is not feasible to declare an individual variable for the index. If the string size is decreased then the fixed variables can give Out of Bound Error. To handle these situations we will use a for loop to traverse the given string and print the corresponding code point.
Example:
C++
#include <iostream>
using namespace std;
int main()
{
char arr[] = "GeEkS" ;
int code;
cout << " Input String = " << arr;
for ( int i = 0; arr[i] != '\0' ; i++) {
code = arr[i];
cout << "\n The Unicode Code Point At " <<i<< " is = " << code;
}
return 0;
}
|
Output
Input String = GeEkS
The Unicode Code Point At 0 is 71
The Unicode Code Point At 1 is 101
The Unicode Code Point At 2 is 69
The Unicode Code Point At 3 is 107
The Unicode Code Point At 4 is 83
Time Complexity: O(n), where n is the array size.
Space Complexity: O(1),
Last Updated :
07 Oct, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...