Paano Mo Mahahanap ang Halaga ng ASCII Ng Isang Character?

Paano Mo Mahahanap ang Halaga ng ASCII Ng Isang Character?

Ang 'ASCII' ay nangangahulugang 'American Standard Code for Information Interchange'. Ang mga code ng ASCII ay kumakatawan sa teksto sa mga computer, kagamitan sa telecommunication, at iba pang mga aparato. Ang ASCII ay nagko-convert ng impormasyon sa standardized digital format na nagpapahintulot sa mga computer na magproseso ng data, mag-imbak ng data, at mahusay na makipag-usap sa ibang mga computer.





Sa artikulong ito, malalaman mo kung paano hanapin ang halaga ng ASCII ng isang character gamit ang C ++, Python, JavaScript, at C.





kung paano makahanap ng may bumulong

Pahayag ng Suliranin

Binigyan ka ng isang character at kailangan mong i-print ang ASCII na halaga ng character na iyon.





Halimbawa 1 : Hayaan ang ibinigay na character na 'M'.

Ang halaga ng ASCII ng 'M' ay 77.



Kaya, ang output ay 77.

Halimbawa 2 : Hayaan ang ibinigay na character na 'U'.





Ang halaga ng ASCII ng 'U' ay 85.

Kaya, ang output ay 85.





Halimbawa 3 : Hayaan ang ibinigay na character na 'O'.

Ang halaga ng ASCII ng 'O' ay 79.

Kaya, ang output ay 79.

Kung nais mong tingnan ang kumpletong talahanayan ng ASCII, maaari kang mag-check out website ng asciitable .

Kaugnay: Ano ang Pagkakaiba sa Pagitan ng ASCII at Unicode Text?

C ++ Program upang Mahahanap ang Halaga ng ASCII ng isang Character

Mahahanap mo ang halaga ng ASCII ng isang character na ginagamit int () sa C ++. Nasa ibaba ang programa ng C ++ upang mai-print ang ASCII na halaga ng isang character:

kung paano gumawa ng nakabalangkas na teksto sa photoshop
// C++ program to find the ASCII value of a character
#include
using namespace std;
int main()
{
char ch1 = 'M';
char ch2 = 'U';
char ch3 = 'O';
char ch4 = 'm';
char ch5 = 'a';
char ch6 = 'k';
char ch7 = 'e';
char ch8 = 'u';
char ch9 = 's';
char ch10 = 'e';
char ch11 = 'o';
char ch12 = 'f';
// int() is used to convert character to its ASCII value
cout << 'ASCII value of ' << ch1 << ' is ' << int(ch1) << endl;
cout << 'ASCII value of ' << ch2 << ' is ' << int(ch2) << endl;
cout << 'ASCII value of ' << ch3 << ' is ' << int(ch3) << endl;
cout << 'ASCII value of ' << ch4 << ' is ' << int(ch4) << endl;
cout << 'ASCII value of ' << ch5 << ' is ' << int(ch5) << endl;
cout << 'ASCII value of ' << ch6 << ' is ' << int(ch6) << endl;
cout << 'ASCII value of ' << ch7 << ' is ' << int(ch7) << endl;
cout << 'ASCII value of ' << ch8 << ' is ' << int(ch8) << endl;
cout << 'ASCII value of ' << ch9 << ' is ' << int(ch9) << endl;
cout << 'ASCII value of ' << ch10 << ' is ' << int(ch10) << endl;
cout << 'ASCII value of ' << ch11 << ' is ' << int(ch11) << endl;
cout << 'ASCII value of ' << ch12 << ' is ' << int(ch12) << endl;

return 0;
}

Output:

ASCII value of M is 77
ASCII value of U is 85
ASCII value of O is 79
ASCII value of m is 109
ASCII value of a is 97
ASCII value of k is 107
ASCII value of e is 101
ASCII value of u is 117
ASCII value of s is 115
ASCII value of e is 101
ASCII value of o is 111
ASCII value of f is 102

Kaugnay: Ano ang Teksto ng ASCII at Paano Ito Ginagamit?

Python Program upang Mahahanap ang Halaga ng ASCII ng isang Character

Mahahanap mo ang halaga ng ASCII ng isang character na ginagamit mga salita () sa Python. Nasa ibaba ang programa ng Python upang mai-print ang ASCII na halaga ng isang character:

# Python program to find the ASCII value of a character
ch1 = 'M'
ch2 = 'U'
ch3 = 'O'
ch4 = 'm'
ch5 = 'a'
ch6 = 'k'
ch7 = 'e'
ch8 = 'u'
ch9 = 's'
ch10 = 'e'
ch11 = 'o'
ch12 = 'f'
# ord() is used to convert character to its ASCII value
print('ASCII value of', ch1, 'is', ord(ch1))
print('ASCII value of', ch2, 'is', ord(ch2))
print('ASCII value of', ch3, 'is', ord(ch3))
print('ASCII value of', ch4, 'is', ord(ch4))
print('ASCII value of', ch5, 'is', ord(ch5))
print('ASCII value of', ch6, 'is', ord(ch6))
print('ASCII value of', ch7, 'is', ord(ch7))
print('ASCII value of', ch8, 'is', ord(ch8))
print('ASCII value of', ch9, 'is', ord(ch9))
print('ASCII value of', ch10, 'is', ord(ch10))
print('ASCII value of', ch11, 'is', ord(ch11))
print('ASCII value of', ch12, 'is', ord(ch12))

Output:

ASCII value of M is 77
ASCII value of U is 85
ASCII value of O is 79
ASCII value of m is 109
ASCII value of a is 97
ASCII value of k is 107
ASCII value of e is 101
ASCII value of u is 117
ASCII value of s is 115
ASCII value of e is 101
ASCII value of o is 111
ASCII value of f is 102

Program sa JavaScript upang Mahahanap ang Halaga ng ASCII ng isang Character

Mahahanap mo ang halaga ng ASCII ng isang character na ginagamit string.charCodeAt (0) sa JavaScript. Nasa ibaba ang programa ng JavaScript upang mai-print ang ASCII na halaga ng isang character:

const ch1 = 'M';
const ch2 = 'U';
const ch3 = 'O';
const ch4 = 'm';
const ch5 = 'a';
const ch6 = 'k';
const ch7 = 'e';
const ch8 = 'u';
const ch9 = 's';
const ch10 = 'e';
const ch11 = 'o';
const ch12 = 'f';

// string.charCodeAt(0) is used to convert character to its ASCII value
document.write('ASCII value of ' + ch1+ ' is ' + ch1.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch2+ ' is ' + ch2.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch3+ ' is ' + ch3.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch4+ ' is ' + ch4.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch5+ ' is ' + ch5.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch6+ ' is ' + ch6.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch7+ ' is ' + ch7.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch8+ ' is ' + ch8.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch9+ ' is ' + ch9.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch10+ ' is ' + ch10.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch11+ ' is ' + ch11.charCodeAt(0) + '
');
document.write('ASCII value of ' + ch12+ ' is ' + ch12.charCodeAt(0) + '
');

Output:

ASCII value of M is 77
ASCII value of U is 85
ASCII value of O is 79
ASCII value of m is 109
ASCII value of a is 97
ASCII value of k is 107
ASCII value of e is 101
ASCII value of u is 117
ASCII value of s is 115
ASCII value of e is 101
ASCII value of o is 111
ASCII value of f is 102

Kaugnay: Paano Bumuo ng isang Simpleng Calculator Gamit ang HTML, CSS, at JavaScript

C Program upang Mahahanap ang Halaga ng ASCII ng isang Character

Mahahanap mo ang halaga ng ASCII ng isang character na ginagamit mga detalye ng format sa C. Nasa ibaba ang programa ng C upang mai-print ang ASCII na halaga ng isang character:

// C program to find the ASCII value of a character
#include
int main()
{
char ch1 = 'M';
char ch2 = 'U';
char ch3 = 'O';
char ch4 = 'm';
char ch5 = 'a';
char ch6 = 'k';
char ch7 = 'e';
char ch8 = 'u';
char ch9 = 's';
char ch10 = 'e';
char ch11 = 'o';
char ch12 = 'f';
// You can print the ASCII value of a character in C using format specifier
// %d displays the integer ASCII value of a character
// %c displays the character itself
printf('ASCII value of %c is %d ⁠n', ch1, ch1);
printf('ASCII value of %c is %d ⁠n', ch2, ch2);
printf('ASCII value of %c is %d ⁠n', ch3, ch3);
printf('ASCII value of %c is %d ⁠n', ch4, ch4);
printf('ASCII value of %c is %d ⁠n', ch5, ch5);
printf('ASCII value of %c is %d ⁠n', ch6, ch6);
printf('ASCII value of %c is %d ⁠n', ch7, ch7);
printf('ASCII value of %c is %d ⁠n', ch8, ch8);
printf('ASCII value of %c is %d ⁠n', ch9, ch9);
printf('ASCII value of %c is %d ⁠n', ch10, ch10);
printf('ASCII value of %c is %d ⁠n', ch11, ch11);
printf('ASCII value of %c is %d ⁠n', ch12, ch12);
return 0;
}

Output:

ASCII value of M is 77
ASCII value of U is 85
ASCII value of O is 79
ASCII value of m is 109
ASCII value of a is 97
ASCII value of k is 107
ASCII value of e is 101
ASCII value of u is 117
ASCII value of s is 115
ASCII value of e is 101
ASCII value of o is 111
ASCII value of f is 102

Buuin ang Iyong Mga Kasanayan sa Programming sa Masaya, Praktikal na Mga Paraan

Nakakatuwa ang pagprograma sa sandaling napabuti mo ito at alam mo ang iyong ginagawa. Maaari kang matuto ng programa sa maraming paraan. Ngunit ang hands-on na paraan ng pag-aaral ng programa ay maaaring makatulong sa iyo na matuto nang mas mabilis at mapanatili ang impormasyon para sa isang mas mahabang tagal ng panahon.

Ang Building Coding Games ay isa sa mga pinakamahusay na pamamaraan upang makakuha ng hands-on na karanasan habang masaya sa parehong oras.

Magbahagi Magbahagi Mag-tweet Email Ang 9 Pinakamahusay na Mga Larong Pag-coding upang Buuin ang Iyong Mga Kasanayan sa Programming

Ang mga laro sa pag-coding ay makakatulong sa iyo na matuto nang mas mabilis sa pamamagitan ng pagsasanay na karanasan at karanasan. Dagdag pa, ang mga ito ay isang nakakatuwang paraan upang subukan ang iyong mga kasanayan sa programa!

Basahin Susunod
Mga Kaugnay na Paksa
  • Programming
  • JavaScript
  • Sawa
  • Mga Tutorial sa Coding
  • C Programming
Tungkol sa May-akda Yuvraj Chandra(60 Mga Artikulo Na-publish)

Si Yuvraj ay isang undergraduate na mag-aaral sa Computer Science sa University of Delhi, India. Masigasig siya sa Full Stack Web Development. Kapag hindi siya nagsusulat, sinisiyasat niya ang lalim ng iba't ibang mga teknolohiya.

Higit pa Mula kay Yuvraj Chandra

Mag-subscribe sa aming newsletter

Sumali sa aming newsletter para sa mga tip sa tech, pagsusuri, libreng ebook, at eksklusibong deal!

Mag-click dito upang mag-subscribe