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.

Answers were Sorted based on User's Feedback



if i want cin 12345678910 and cout abcdefghij. so how can i create the program?. example : if i ke..

Answer / 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

if i want cin 12345678910 and cout abcdefghij. so how can i create the program?. example : if i ke..

Answer / 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

if i want cin 12345678910 and cout abcdefghij. so how can i create the program?. example : if i ke..

Answer / archana

U can Use switch case for this

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C++ General Interview Questions

Will c++ be replaced?

0 Answers  


Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

0 Answers  


If a base class is an adt, and it has three pure virtual functions, how many of these functions must be overridden in its derived classes?

0 Answers  


What is the precedence when there is a global variable and a local variable in the program with the same name?

0 Answers  


Will a catch statement catch a derived exception if it is looking for the base class?

0 Answers  






How to implement flags?

2 Answers   Symphony,


What is std :: endl?

0 Answers  


What are C++ inline functions?

1 Answers  


What is atoi in c++?

0 Answers  


What are the benefits of oop in c++?

0 Answers  


What are the uses of pointers?

0 Answers  


When is a template a better solution than a base class?

1 Answers  


Categories