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

What is the use of object in c++?

0 Answers  


Describe private, protected and public – the differences and give examples.

0 Answers  


What is setiosflags c++?

0 Answers  


how to access grid view row?

0 Answers  


Why do we use pointers in c++?

0 Answers  






Tell me an example where stacks are useful?

0 Answers  


What is the use of volatile variable?

0 Answers  


Write a program to read the data and evaluate the results of the election. Print all output to the screen. Your output should specify: The total number of votes, the number of valid votes and the number of spoilt votes. The winner(s) of the election. Hint: An appropriate search should be used to determine the winner(s). The votes obtained by each candidate sorted in terms of the number of votes obtained. Hint: An appropriate sort should be used to sort the candidate(s). The Source code should be saved as VotingSystem. Project Input: Candidates’ Names and Numbers 2501 Victor Taylor 2502 Denise Duncan 2503 Kamal Ramdhan 2504 Michael Ali 2505 Anisa Sawh 2506 Carol Khan 2507 Gary Owen Votes 3 1 2 5 4 3 5 3 5 3 2 8 1 6 7 7 3 5 6 9 3 4 7 1 2 4 5 5 1 4 0 Project Output: Invalid vote: 8 Invalid vote: 9 Number of voters: 30 Number of valid votes: 28 Number of spoilt votes: 2 The winner(s): 2503 Kamal Ramdhan 2505 Anisa Sawh Candidate Score 2503 Kamal Ramdhan 6 2505 Anisa Sawh 6 2501 Victor Taylor 4 2504 Michael Ali 4 2502 Denise Duncan 3 2507 Gary Owen 3 2506 Carol Khan 2

0 Answers  


Can java be faster than c++?

0 Answers  


program explaining feautures of c++

0 Answers   Satyam,


What is c++ manipulator?

0 Answers  


Difference between a copy constructor and an assignment operator.

0 Answers  


Categories