In C, you can use the int data type to represent ASCII values. Each character in the ASCII table is assigned a unique number between 0 and 127. To get the ASCII value of a character, you can simply cast it to an int. Here's an example:

char c = 'A';

int asciiValue = (int)c;

printf("The ASCII value of '%c' is %d\n", c, asciiValue);

This will output:

The ASCII value of 'A' is 65

Alternatively you can also use the 'C' library function (int)c to get the ASCII value of a character.

char c = 'A';

int asciiValue = (int)c;

printf("The ASCII value of '%c' is %d\n", c, asciiValue);

will give you the same output.

You can also find the ASCII value of a character with a function like getchar(), that returns an int value of the char type that it reads from the keyboard, or with a function like scanf() that reads a character input.

Additionally, if you want to find the ASCII value of a string, you can use a for loop to iterate through each character of the string and then get the ASCII value of each character by casting it to an int.



Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu