Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What operators can you overload in c++?

992


Describe the role of the c++ in the tradeoff of safety vs. Usability?

1160


What is the use of seekg in c++?

991


What is vector processing?

1113


Where do I find the current c or c++ standard documents?

1026


What is the use of cmath in c++?

1006


How long does it take to get good at leetcode?

1116


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

1008


Is c++ fully object oriented?

916


What are signs of manipulation?

1013


How are the features of c++ different from c?

1015


What are vtable and vptr?

1079


Why do we use the using declaration?

1118


Can class objects be passed as function arguments?

1012


Is c++ a high level language?

944