문자의 ASCII 값을 찾는 방법은 무엇입니까?

문자의 ASCII 값을 찾는 방법은 무엇입니까?

'ASCII'는 'American Standard Code for Information Interchange'의 약자입니다. ASCII 코드는 컴퓨터, 통신 장비 및 기타 장치의 텍스트를 나타냅니다. ASCII는 컴퓨터가 데이터를 처리하고, 데이터를 저장하고, 다른 컴퓨터와 효율적으로 통신할 수 있도록 정보를 표준화된 디지털 형식으로 변환합니다.





이 기사에서는 C++, Python, JavaScript 및 C를 사용하여 문자의 ASCII 값을 찾는 방법을 배웁니다.





한 컴퓨터에서 다른 컴퓨터로 사진을 전송하는 방법

문제 설명

문자가 주어지고 해당 문자의 ASCII 값을 인쇄해야 합니다.





실시예 1 : 주어진 문자를 'M'으로 한다.

'M'의 ASCII 값은 77입니다.



따라서 출력은 77입니다.

실시예 2 : 주어진 문자를 'U'로 합니다.





'U'의 ASCII 값은 85입니다.

따라서 출력은 85입니다.





실시예 3 : 주어진 문자를 'O'로 한다.

'O'의 ASCII 값은 79입니다.

따라서 출력은 79입니다.

전체 ASCII 테이블을 보려면 다음을 확인하십시오. ascitable의 웹사이트 .

관련된: ASCII와 유니코드 텍스트의 차이점은 무엇입니까?

문자의 ASCII 값을 찾는 C++ 프로그램

다음을 사용하여 문자의 ASCII 값을 찾을 수 있습니다. 정수() C++에서. 다음은 문자의 ASCII 값을 인쇄하는 C++ 프로그램입니다.

Surface Pro 7에서 스크린샷을 찍는 방법
// 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;
}

산출:

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

관련된: ASCII 텍스트란 무엇이며 어떻게 사용됩니까?

문자의 ASCII 값을 찾는 Python 프로그램

다음을 사용하여 문자의 ASCII 값을 찾을 수 있습니다. 단어() 파이썬에서. 다음은 문자의 ASCII 값을 인쇄하는 Python 프로그램입니다.

# 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))

산출:

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

문자의 ASCII 값을 찾는 JavaScript 프로그램

다음을 사용하여 문자의 ASCII 값을 찾을 수 있습니다. string.charCodeAt(0) 자바스크립트에서. 다음은 문자의 ASCII 값을 인쇄하는 JavaScript 프로그램입니다.

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) + '
');

산출:

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

관련: HTML, CSS 및 JavaScript를 사용하여 간단한 계산기를 만드는 방법

문자의 ASCII 값을 찾는 C 프로그램

다음을 사용하여 문자의 ASCII 값을 찾을 수 있습니다. 형식 지정자 다음은 문자의 ASCII 값을 인쇄하는 C 프로그램입니다.

// 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;
}

산출:

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

재미있고 실용적인 방법으로 프로그래밍 기술을 구축하세요

프로그래밍을 잘하고 무엇을 하고 있는지 알게 되면 프로그래밍은 재미있습니다. 다양한 방법으로 프로그래밍을 배울 수 있습니다. 그러나 프로그래밍 학습의 실습 방법은 더 빨리 배우고 정보를 더 오랜 기간 동안 유지하는 데 도움이 될 수 있습니다.

코딩 게임 만들기는 재미를 느끼면서 실제 경험을 얻을 수 있는 가장 좋은 방법 중 하나입니다.

공유하다 공유하다 트위터 이메일 프로그래밍 기술을 구축할 수 있는 최고의 코딩 게임 9가지

코딩 게임은 실습과 경험을 통해 더 빨리 배울 수 있도록 도와줍니다. 또한, 프로그래밍 기술을 테스트할 수 있는 재미있는 방법입니다!

다음 읽기
관련 항목
  • 프로그램 작성
  • 자바스크립트
  • 파이썬
  • 코딩 튜토리얼
  • C 프로그래밍
저자 소개 유브라지 찬드라(60편 게재)

Yuvraj는 인도 델리 대학교의 컴퓨터 공학 학부생입니다. 그는 풀 스택 웹 개발에 열정적입니다. 그는 글을 쓰지 않을 때 다양한 기술의 깊이를 탐구하고 있습니다.

유브라지 찬드라가 참여한 작품 더보기

뉴스레터 구독

뉴스레터에 가입하여 기술 팁, 리뷰, 무료 전자책 및 독점 거래를 확인하십시오!

구독하려면 여기를 클릭하세요.