0

In c++ how would I create a code where If I press 'A' in the input, it then output '1' and for 'B' 2 and so on

7th Nov 2022, 8:21 AM
Sarel
Sarel - avatar
2 Antworten
0
You can literally hardcoded it using switch() statement, Or Just dirrectly convert character into integer minus 64 (A is 65 in Acii) like: int main() { char c; cin >> c; int num = c; cout << num - 64; return 0; }
7th Nov 2022, 1:32 PM
Muhamad Iqbal Chaniago
Muhamad Iqbal Chaniago - avatar
0
Thx 🌱
7th Nov 2022, 1:50 PM
Sarel
Sarel - avatar