4 Alphabetic Characters - The principal types of graphemes are logograms (more accurately termed morphograms), which represent words or morphemes (for example chinese characters, the ampersand & representing the word and, arabic numerals);
Set the range of the outer and inner loop according to the string length. Print the str character as the pattern with the help of index…