C Strings

Arithmetic operations on characters

We can also manipulate the characters as we manipulate numbers in c language. When ever the system encounters the character data it is automatically converted into a integer value by the system. We can represent a character as a interface by using the following method.
	for example:
	          	X=’a’; 
		     	Printf(“%d\n”,x); 
        


Details about topic

Example Will display 97 on the screen. Arithmetic operations can also be performed on characters for example x=’z’-1; is a valid statement. The ASCII value of ‘z’ is 122 the statement the therefore will assign 121 to variable x.
It is also possible to use character constants in relational expressions for example
ch>’a’ && ch < = ’z’

will check whether the character stored in variable ch is a lower case letter. A character digit can also be converted into its equivalent integer value suppose un the expression
a=character-‘1’;

where a is defined as an integer variable & character contains value 8 then a= ASCII value of 8 ASCII value ‘1’=56-49=7.

Make Comments..!!


Oops!! No posts from user.

Download Android App