Examples on Characters and ASCII Values in C || Lesson 28.3 || C Programming || Learning Monkey ||

Examples on Characters and ASCII Values in C || Lesson 28.3 || C Programming || Learning Monkey ||

Examples on Characters and ASCII Values in C

In this class, we will try to understand Examples of Characters and ASCII Values in C.

We have already explained character datatype and ASCII codes.

We can use the ASCII codes either as a character or as an integer.

We will try to understand this by using an example.


Examples on Characters and ASCII Values
Example 1


In the above example, we have defined a character variable ch with value A.

As the ASCII code is 65, the compiler will store the binary value (10000001) of 65 in “ch.”

In the printf statement, we are printing the value stored in “ch” in its integer format and corresponding character format.
Example 2
In the above example, we have done an increment operation on the character variable.

Even though it is a character variable, we can do arithmetic operations also.

The first printf in the above program prints, ” The character A has an ASCII code of 65.”

In the following line of code, the value stored in ch will get incremented to 66.

The second printf in the above program prints, ” The character B has an ASCII code of 66.”

The point that we have to understand is we can perform arithmetic operations on character variables.




#learningmonkey #cprogrammingforbeginners #placements #gatecse #cprogramming #cprogramminglanguage




Link for playlists:
https://www.youtube.com/channel/UCl8x4Pn9Mnh_C1fue-Yndig/playlists


Link for our website: https://learningmonkey.in

Follow us on Facebook @ https://www.facebook.com/learningmonkey

Follow us on Instagram @ https://www.instagram.com/learningmonkey1/

Follow us on Twitter @ https://twitter.com/_learningmonkey

Mail us @ learningmonkey01@gmail.com

Examples on Characters and ASCII Values in Ccharacter variables in cchar data type

Post a Comment

0 Comments