TopBottom

Followers



Click on more
SUBSCRIBE

Enter your email address:

Delivered by FeedBurner



VIDEO

Announcement: wanna exchange links? contact me at ravikrak@yahoo.com

Arithemetic Operations On Characters

Posted by Ravi Kumar at Friday, September 23, 2011
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

'C' allows us to manipulate characters in the same
way we do with numbers.Whenever a character constant or
character variable is used in an expression , it is
automatically converted to integer value by the system .
Integer value depends on local character set of the system .
If the machine uses the ASCII representation then
x = 'a';
printf("%d", x);
will display the number 97 on the screen.

ex: x = 'z'-1; is a valid statement
In ASCII , the value of 'z' is 122 , therefore the value
121 is assigned to x.
The 'c' library supports a function that converts a string
of digits into their integer values .
The function takes the form
x = atoi(string);
x is an integer variable and string is a character
array containing a string of digits.
ex: ------------------
number = "1988";
year = atoi(number);
The function converts the string "1988" to its numeric
equivalent 1988 and assigns it to the integer variable year

Share |

Labels:

0 comments:

Post a Comment