if i want cin 12345678910 and cout abcdefghij.
so how can i create the program?.
example : if i key in 8910 so the answer is ghij.
Answer Posted / mms zubeir
I am roughly writing this code and this can be optimized.
void main()
{
unsigned int input = 0;
cin>>input;
int inputArray[10]; // the integer range can be 0
to 4294967295.
char carr[11]; // since the integer limit is 10
digits for 4 bytes allocation.
int index = 0;
while(input > 0)
{
inputArray[index] = input % 10;
input = input / 10;
++index;
}
cout<<endl<<"character equivalents: "<<endl;
for(int i = index-1; i>=0; --i)
{
if(inputArray[i] == 0) inputArray[i] =
10; // to represent 0 = j for our calculation.
carr[index-i] =
char_traits<char>::to_int_type ('a') - 1 + inputArray[i];
cout<<endl<<carr[index-i]; // displays the
output.
}
getch();
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
If dog is a friend of boy, and terrier derives from dog, is terrier a friend of boy?
What is std namespace in c++?
Is c++ an integer?
What is virtual destructor ans explain its use?
Who was the creator of c++?
Why the usage of pointers in C++ is not recommended ?
Do class declarations end with a semicolon? Do class method definitions?
Explain the difference between c++ and java.
If you push the numbers (in order) 1, 3, and 5 onto a stack, which pops out first a) 1 b) 5 c) 3
What is the difference between an enumeration and a set of pre-processor # defines?
How does java differ from c and c++?
What can I safely assume about the initial values of variables which are not explicitly initialized?
What are all predefined data types in c++?
You run a shell on unix system. How would you tell which shell are you running?
What is the main use of c++?