Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 1
Can Anyone Make An Alpha Numeric Converter?But With A Twist!
We Know That Alpha Numeric Converter Are Of Two Types I.e,1]Input Letter A and get 1 in return ;Though This Is Easy, But Im Confused On How To Make The Opposite I.e,the 2nd One]Input Number 1 and get A.Can Anyone Help Me With That?Please In c++.
6 Answers
+ 6
Alternatively you can also convert the input into its alphabetical representation by using ASCII code.
#include <iostream>
int main()
{
int num;
// Read on until no more input
while(std::cin >> num)
{
// Only accept a range of 1 ~ 26
if(num > 0 && num < 27)
// Replace 64 with 96 to get the
// lowercase alphabets
std::cout << char(num + 64) << "\n";
}
}
+ 12
You can make an array of characters where the 0 index is empty.
When the user inputs a number, output using the index.
in: 1
cout characters[in] returns A
in: 2
cout characters[in] returns B
+ 2
Thanks!
+ 2
You're welcome Legend Xtreme 79 : )
+ 1
pretty good idea ipang
+ 1
thanks