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
What is the header file for setw?
How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?
What are the uses of pointers?
What is istream and ostream in c++?
What is a volatile variable in c++?
What is a .h file c++?
What is a buffer c++?
What is the full form of india?
In int main(int argc, char *argv[]) what is argv[0] a) The first argument passed into the program b) The program name c) You can't define main like that
What is ctime c++?
Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.
What is meant by a delegate?
What is different in C++, compare with unix?
What flag means?
Explain linear search.