Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • C
  • C Basics
  • C Data Types
  • C Operators
  • C Input and Output
  • C Control Flow
  • C Functions
  • C Arrays
  • C Strings
  • C Pointers
  • C Preprocessors
  • C File Handling
  • C Programs
  • C Cheatsheet
  • C Interview Questions
  • C MCQ
  • C++
Open In App
Next Article:
C Program For Char to Int Conversion
Next article icon

C Program to Determine the Unicode Code Point at a Given Index

Last Updated : 04 Jul, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Unicode is the encoding mechanism to assign a unique number to each character. The first 128 characters are assigned as ASCII value means Unicode and ASCII value for the first 128 characters is the same. The first 128 characters contain the English Alphabet, Digits, Special Characters, etc. ASCII values are different for uppercase English alphabets and lowercase alphabets.

TypesStarting ValueEnding Value
Uppercase Alphabets6590
Lowercase Alphabets97122

From the table above one can understand that starting Uppercase letter i.e 'A' will have a value of 65 and ending at 'Z' with 90. Similarly lowercase 'a' is 97 and ends at 'z' with 122.

The C language has an implicit mapping of the 'char' data type to int which uses these Unicode values or ASCII values.

There are 2 ways to determine the unicode code point at a given index in C:

  1. Returning value at index after storing in "int" datatype.
  2. Using for Loop

1. Returning value at index after storing in int datatype

Below is the C++ program to determine Unicode code point at a given index:

C
// C++ program to determine unicode  // code point at a given index #include <stdio.h>  // Driver code int main() {   char arr[10] = "GeEkS";   int index1 = 0, index2 = 1,        index3 = 2, index4 = 3,       index5 = 4, code;   printf("The String is %s\n", arr);    code = arr[index1];   printf("The Unicode Code Point At %d is:%d\n",            index1, code);   code = arr[index2];   printf("The Unicode Code Point At %d is:%d\n",            index2, code);   code = arr[index3];   printf("The Unicode Code Point At %d is:%d\n",            index3, code);   code = arr[index4];   printf("The Unicode Code Point At %d is:%d\n",            index4, code);   code = arr[index5];   printf("The Unicode Code Point At %d is:%d\n",            index5, code);   return 0; } 

Output
The String is 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) 
  • Space Complexity: O(2*n+1) = O(n)

2. Using for loop

If the string value is increased then it is not feasible to declare an individual variable for the index. Also if the string size is decreased then the fixed variables can give Out of Bound Error. To handle these situations we will use for loop to traverse the string and print the corresponding code point.

Below is the C program to determine unicode code point at a given index:

C
// C program to determine the unicode // code point at a given index #include <stdio.h>  // Driver code int main() {   char arr[10] = "GeEkS";   int code;   printf("The String is %s\n",            arr);      for (int i = 0; arr[i] != '\0'; i++)    {     code = arr[i];     printf("The Unicode Code Point At %d is:%d\n",              i, code);   }   return 0; } 

Output
The String is 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)
  • Space Complexity: O(1)

Next Article
C Program For Char to Int Conversion

S

sunnydrall
Improve
Article Tags :
  • C Programs
  • C Language
  • C Strings Programs

Similar Reads

  • Program to print the Alphabets of a Given Word using * pattern
    Given a word str, the task is to print the alphabets of this word using * pattern.Examples: Input: GFGOutput: ****** * * * * **** * * * * * * *** * ******* ** ** ****** ** ** ** ****** * * * * **** * * * * * * *** *Approach: A simple implementation is to form the pattern for each letter A-Z and call
    15+ min read
  • C program to find the frequency of characters in a string
    Given a string S containing lowercase English characters, the task is to find the frequency of all the characters in the string. ExamplesInput: S="geeksforgeeks" Output: e - 4 f - 1 g - 2 k - 2 o - 1 r - 1 s - 2 Input: S="gfg" Output: f - 1 g - 2Approach Follow the steps to solve the problem: Initia
    2 min read
  • Program and syntax for iscntrl(int c) function in C
    In C, iscntrl() is a predefined function used for string and character handling. ctype is the header file required for character functions. A control character is one that is not a printable character i.e, it does not occupy a printing position on a display. This function is used to check if the arg
    4 min read
  • C Program For Char to Int Conversion
    Write a C program to convert the given numeric character to integer. Example: Input: '3'Output: 3Explanation: The character '3' is converted to the integer 3. Input: '9'Output: 9Explanation: The character '9' is converted to the integer 9. Different Methods to Convert the char to int in CThere are 3
    3 min read
  • C Program To Find Initials of a Name
    Here, we will see how to find the initials of a name using a C program. Below are the examples: Input: Geeks for GeeksOutput: G F GWe take the first letter of allwords and print in capital letter. Input: Jude LawOutput: J L Approach: Print the first character in the capital. Traverse the rest of the
    2 min read
  • Lex Program to Find if a Character Apart from Alphabet Occurs in a String
    Lex is a computer program that generates lexical analyzers. Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lexer in the C programming language. The commands for executing the lex program are: lex abc.l (abc is the file name) cc lex.yy.c ./a.out Pro
    3 min read
  • C Program to Check if String is Pangram
    Given a string Str. The task is to check if it is Pangram or not.  A pangram is a sentence containing every letter in the English Alphabet. Examples:  Input: "The quick brown fox jumps over the lazy dog" Output: is a Pangram Explanation: Contains all the characters from ‘a’ to ‘z’]  Input: "The quic
    3 min read
  • C Program to Check Vowel or Consonant
    In English, there are 5 vowel letters and 21 consonant letters. In lowercase alphabets, 'a', 'e', 'i', 'o', and 'u' are vowels and all other characters ('b', 'c', 'd, 'f'....) are consonants. Similarly in uppercase alphabets, 'A', 'E', 'I', 'O', and 'U' are vowels, and the rest of the characters are
    3 min read
  • Find the Length of Character Array in C
    In C, a character array is a collection of elements of the ‘char’ data type that are placed in contiguous memory locations and are often used to store strings. The length of a character array is defined as the total number of characters present in the array, excluding the null character ('\0') at th
    2 min read
  • ASCII Value of a Character in C
    In this article, we will discuss about the ASCII values that are bit numbers used to represent the character in the C programming language. We will also discuss why the ASCII values are needed and how to find the ASCII value of a given character in a C program. Table of Content What is ASCII Value o
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences