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

If dog is a friend of boy, and terrier derives from dog, is terrier a friend of boy?

1025


What is std namespace in c++?

1160


Is c++ an integer?

1017


What is virtual destructor ans explain its use?

1115


Who was the creator of c++?

1033


Why the usage of pointers in C++ is not recommended ?

1420


Do class declarations end with a semicolon? Do class method definitions?

1134


Explain the difference between c++ and java.

1100


If you push the numbers (in order) 1, 3, and 5 onto a stack, which pops out first a) 1 b) 5 c) 3

1365


What is the difference between an enumeration and a set of pre-processor # defines?

1367


How does java differ from c and c++?

974


What can I safely assume about the initial values of variables which are not explicitly initialized?

1041


What are all predefined data types in c++?

1114


You run a shell on unix system. How would you tell which shell are you running?

1158


What is the main use of c++?

1113