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


Please Help Members By Posting Answers For Below Questions

Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].

689


Does c++ have foreach?

626


Differentiate between an array and a list?

813


What is the hardest coding language to learn?

701


What are the advantages of early binding?

700






What do you mean by public protected and private in c++?

696


Which operator cannot be overloaded c++?

674


Which is best c++ or java?

740


If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?

1115


What is binary search in c++?

684


What is function prototyping?

707


List different attributes in C++?

731


How long does it take to get good at leetcode?

762


What is the disadvantage of using a macro?

681


How do you add an element to a set in c++?

643